From 9991f14fced25dac3699b473a05cc7a196f9220e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mehmet=20Emin=20=C4=B0NA=C3=87?= Date: Tue, 14 Apr 2015 22:50:36 +0300 Subject: Fix for has_and_belongs_to_many & has_many_through associations while partial_writes is false This will fix #19663 Also with this fix, active record does not fire unnecassary update queries while partial_writes is true --- .../lib/active_record/associations/has_many_through_association.rb | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'activerecord/lib') diff --git a/activerecord/lib/active_record/associations/has_many_through_association.rb b/activerecord/lib/active_record/associations/has_many_through_association.rb index 36fc381343..7ddb96db13 100644 --- a/activerecord/lib/active_record/associations/has_many_through_association.rb +++ b/activerecord/lib/active_record/associations/has_many_through_association.rb @@ -86,7 +86,10 @@ module ActiveRecord end def save_through_record(record) - build_through_record(record).save! + association = build_through_record(record) + if association.changed? + association.save! + end ensure @through_records.delete(record.object_id) end -- cgit v1.2.3