aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/lib/active_record/autosave_association.rb
diff options
context:
space:
mode:
authorEloy Duran <eloy.de.enige@gmail.com>2009-07-11 17:52:13 +0200
committerEloy Duran <eloy.de.enige@gmail.com>2009-09-12 15:53:15 +0200
commit6cc0b9638fbb6ede3c46b51d7dab17881416014c (patch)
treefbfa46d9165f5c60c24939ef53dfecf28db23ea9 /activerecord/lib/active_record/autosave_association.rb
parent1b78e9bba3bd39c4669ff6c640b7df069185c22c (diff)
downloadrails-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/active_record/autosave_association.rb')
-rw-r--r--activerecord/lib/active_record/autosave_association.rb6
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?