Class: Basepack::Forms::Fields::HasManyAssociation
- Defined in:
- lib/basepack/forms/fields/has_many_association.rb
Direct Known Subclasses
Constant Summary
Constants inherited from Base
Instance Attribute Summary
Attributes inherited from Base
Instance Method Summary collapse
- #build_resource ⇒ Object
-
#bulk_editable? ⇒ Boolean
returns true only for for N-N associations.
- #parse_input(params) ⇒ Object
Methods inherited from Base
#association?, #configure_nested_form, #copy, #enum_options, #initialize, #inverse_of_nested_in?, #nested_label, #nform, #unique?, #update_attributes, #value, #view
Constructor Details
This class inherits a constructor from Basepack::Forms::Fields::Base
Instance Method Details
#build_resource ⇒ Object
21 22 23 24 |
# File 'lib/basepack/forms/fields/has_many_association.rb', line 21 def build_resource # TODO - raise exception for `through' assoc: form.resource_class.reflect_on_association(name).nested? value.build end |
#bulk_editable? ⇒ Boolean
returns true only for for N-N associations
35 36 37 38 39 40 41 42 43 44 45 46 |
# File 'lib/basepack/forms/fields/has_many_association.rb', line 35 def bulk_editable? #N-N association are only with: # has_many through: <join_table>, where join_table has foreign_keys for both associations reflection = abstract_model.model.reflect_on_association(name) ( (ActiveRecord::Reflection::ThroughReflection === reflection) and (reflection.through_reflection.macro == :has_many) and (reflection.source_reflection.macro == :belongs_to) ) end |
#parse_input(params) ⇒ Object
26 27 28 29 30 31 32 |
# File 'lib/basepack/forms/fields/has_many_association.rb', line 26 def parse_input(params) if params[method_name].is_a? String params[method_name] = params[method_name].split ',' else @delegate.parse_input(params) if @delegate end end |