From bda16eb0920780509467bcf051d1a01639357903 Mon Sep 17 00:00:00 2001 From: Chiel Wester Date: Mon, 13 Dec 2010 15:06:23 +0100 Subject: Only call save on belongs_to associations if the record has changed or any nested associations have changed (resolves #3353) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: José Valim --- activerecord/lib/active_record/autosave_association.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'activerecord/lib/active_record') diff --git a/activerecord/lib/active_record/autosave_association.rb b/activerecord/lib/active_record/autosave_association.rb index c3dda29d03..4a18719551 100644 --- a/activerecord/lib/active_record/autosave_association.rb +++ b/activerecord/lib/active_record/autosave_association.rb @@ -363,7 +363,7 @@ module ActiveRecord if autosave && association.marked_for_destruction? association.destroy elsif autosave != false - saved = association.save(:validate => !autosave) if association.new_record? || autosave + saved = association.save(:validate => !autosave) if association.new_record? || (autosave && association.changed_for_autosave?) if association.updated? association_id = association.send(reflection.options[:primary_key] || :id) -- cgit v1.2.3