Module: FreeForm::Nested::ClassMethods

Defined in:
lib/freeform/form/nested.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#nested_formsObject

Nested Forms




10
11
12
# File 'lib/freeform/form/nested.rb', line 10

def nested_forms
  @nested_forms
end

Instance Method Details

#nested_form(attribute, options = {}) ⇒ Object Also known as: has_many, has_one



12
13
14
15
16
17
18
19
20
21
22
23
24
25
# File 'lib/freeform/form/nested.rb', line 12

def nested_form(attribute, options={})
  nested_form_class = options[:class]
  @nested_forms ||= {}
  @nested_forms.merge!({:"#{attribute}" => nested_form_class})

  # Define an attr_accessor for the parent class to hold this attribute
  declared_model(attribute)

  # Defined other methods
  define_nested_model_methods(attribute, nested_form_class, options)

  # Setup Handling for nested attributes
  define_nested_attribute_methods(attribute, nested_form_class)
end