From 6cc0b9638fbb6ede3c46b51d7dab17881416014c Mon Sep 17 00:00:00 2001 From: Eloy Duran Date: Sat, 11 Jul 2009 17:52:13 +0200 Subject: Explicitely setting `autosave => false' should override new_record autosaving. [#2214 state:resolved] Original author is Jacob. --- activerecord/lib/active_record/autosave_association.rb | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'activerecord/lib') 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? -- cgit v1.2.3