Module: Restorm::Model::NestedAttributes::ClassMethods
- Defined in:
- lib/restorm/model/nested_attributes.rb
Instance Method Summary collapse
-
#accepts_nested_attributes_for(*associations) ⇒ Object
Allow nested attributes for an association.
Instance Method Details
#accepts_nested_attributes_for(*associations) ⇒ Object
Allow nested attributes for an association
23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 |
# File 'lib/restorm/model/nested_attributes.rb', line 23 def accepts_nested_attributes_for(*associations) allowed_association_names = association_names associations.each do |association_name| unless allowed_association_names.include?(association_name) raise Restorm::Errors::AssociationUnknownError, "Unknown association name :#{association_name}" end class_eval " if method_defined?(:\#{association_name}_attributes=)\n remove_method(:\#{association_name}_attributes=)\n end\n\n def \#{association_name}_attributes=(attributes)\n self.\#{association_name}.assign_nested_attributes(attributes)\n end\n RUBY\n end\nend\n", __FILE__, __LINE__ + 1 |