Module: StoreModel::NestedAttributes::ClassMethods
- Defined in:
- lib/store_model/nested_attributes.rb
Overview
:nodoc:
Instance Method Summary collapse
-
#accepts_nested_attributes_for(*attributes) ⇒ Object
Enables handling of nested StoreModel::Model attributes.
Instance Method Details
#accepts_nested_attributes_for(*attributes) ⇒ Object
Enables handling of nested StoreModel::Model attributes
Alternatively, use the standard Rails syntax:
Supported options:
- :allow_destroy
-
If true, destroys any members from the attributes hash with a
_destroykey and a value that evaluates totrue(e.g. 1, ‘1’, true, or ‘true’). This option is off by default. - :reject_if
-
Allows you to specify a Proc or a Symbol pointing to a method that checks whether a record should be built for a certain attribute hash. The hash is passed to the supplied Proc or the method and it should return either true or false. Passing
:all_blankinstead of a Proc will create a proc that will reject a record where all the attributes are blank excluding any value for_destroy.
37 38 39 40 41 42 43 44 45 46 47 48 |
# File 'lib/store_model/nested_attributes.rb', line 37 def accepts_nested_attributes_for(*attributes) = attributes. attributes.each do |attribute, | case attribute_types[attribute.to_s] when Types::OneBase, Types::ManyBase define_store_model_attr_accessors(attribute, || ) else super(attribute, || ) end end end |