diff options
author | Eloy Duran <eloy.de.enige@gmail.com> | 2009-11-06 23:53:33 +0100 |
---|---|---|
committer | Eloy Duran <eloy.de.enige@gmail.com> | 2009-11-07 00:42:42 +0100 |
commit | f125a34501e21b1e0da2b80d149df7a739482804 (patch) | |
tree | f7094f45c45ef64e5b110130bfe6ff41a4ae801a /activerecord/lib | |
parent | c2cfb201984f8dff2b3534163b6145fe2560eb80 (diff) | |
download | rails-f125a34501e21b1e0da2b80d149df7a739482804.tar.gz rails-f125a34501e21b1e0da2b80d149df7a739482804.tar.bz2 rails-f125a34501e21b1e0da2b80d149df7a739482804.zip |
Define autosave association callbacks when using accepts_nested_attributes_for.
This way we don't define all the validation methods for all associations by
default, but only when needed.
[#3355 state:resolved]
Diffstat (limited to 'activerecord/lib')
-rw-r--r-- | activerecord/lib/active_record/nested_attributes.rb | 2 |
1 files changed, 2 insertions, 0 deletions
diff --git a/activerecord/lib/active_record/nested_attributes.rb b/activerecord/lib/active_record/nested_attributes.rb index edcf547e01..ca3110a374 100644 --- a/activerecord/lib/active_record/nested_attributes.rb +++ b/activerecord/lib/active_record/nested_attributes.rb @@ -250,6 +250,8 @@ module ActiveRecord assign_nested_attributes_for_#{type}_association(:#{association_name}, attributes) end }, __FILE__, __LINE__ + + add_autosave_association_callbacks(reflection) else raise ArgumentError, "No association found for name `#{association_name}'. Has it been defined yet?" end |