Class: Handlers::Relations

Inherits:
Base
  • Object
show all
Defined in:
lib/handlers/relations.rb

Instance Method Summary collapse

Methods inherited from Base

handle, #initialize, #raise_error, #upper

Constructor Details

This class inherits a constructor from Handlers::Base

Instance Method Details

#affect_relation_values!Object



5
6
7
8
9
10
11
12
13
14
# File 'lib/handlers/relations.rb', line 5

def affect_relation_values!
  relation_keys = upper(:@@relation_keys) || {}
  {}.merge(@params).each_key do |key|
    if relation_keys.include?(key.to_sym)
      raise_error("relation named :#{key} must be an ActiveRecord instance not a #{@params[key].class}. Check the params you sent to this form.") unless @params[key].respond_to?(:id)

      @params["#{key}_id"] = @params[key].id
    end
  end
end