12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
|
# File 'lib/active_data/model/nested_attributes.rb', line 12
def accepts_nested_attributes_for *attr_names
attr_names.each do |association_name|
reflection = reflect_on_association association_name
type = (reflection.collection? ? :collection : :one_to_one)
class_eval " if method_defined?(:\#{association_name}_attributes=)\n remove_method(:\#{association_name}_attributes=)\n end\n def \#{association_name}_attributes=(attributes)\n assign_nested_attributes_for_\#{type}_association(:\#{association_name}, attributes)\n end\n EOS\n end\nend\n", __FILE__, __LINE__ + 1
|