diff options
author | Eloy Duran <eloy.de.enige@gmail.com> | 2009-07-11 17:52:13 +0200 |
---|---|---|
committer | Eloy Duran <eloy.de.enige@gmail.com> | 2009-09-12 15:53:15 +0200 |
commit | 6cc0b9638fbb6ede3c46b51d7dab17881416014c (patch) | |
tree | fbfa46d9165f5c60c24939ef53dfecf28db23ea9 /activerecord/lib | |
parent | 1b78e9bba3bd39c4669ff6c640b7df069185c22c (diff) | |
download | rails-6cc0b9638fbb6ede3c46b51d7dab17881416014c.tar.gz rails-6cc0b9638fbb6ede3c46b51d7dab17881416014c.tar.bz2 rails-6cc0b9638fbb6ede3c46b51d7dab17881416014c.zip |
Explicitely setting `autosave => false' should override new_record autosaving. [#2214 state:resolved]
Original author is Jacob.
Diffstat (limited to 'activerecord/lib')
-rw-r--r-- | activerecord/lib/active_record/autosave_association.rb | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/activerecord/lib/active_record/autosave_association.rb b/activerecord/lib/active_record/autosave_association.rb index ebd47ec634..aff29dcc4e 100644 --- a/activerecord/lib/active_record/autosave_association.rb +++ b/activerecord/lib/active_record/autosave_association.rb @@ -285,7 +285,7 @@ module ActiveRecord records.each do |record| if autosave && record.marked_for_destruction? association.destroy(record) - elsif @new_record_before_save || record.new_record? + elsif autosave != false && (@new_record_before_save || record.new_record?) if autosave association.send(:insert_record, record, false, false) else @@ -316,7 +316,7 @@ module ActiveRecord if autosave && association.marked_for_destruction? association.destroy - elsif new_record? || association.new_record? || association[reflection.primary_key_name] != id || autosave + elsif autosave != false && (new_record? || association.new_record? || association[reflection.primary_key_name] != id || autosave) association[reflection.primary_key_name] = id association.save(!autosave) end @@ -337,7 +337,7 @@ module ActiveRecord if autosave && association.marked_for_destruction? association.destroy - else + elsif autosave != false association.save(!autosave) if association.new_record? || autosave if association.updated? |