aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/lib
diff options
context:
space:
mode:
authorArthur Neves <arthurnn@gmail.com>2016-10-28 17:15:23 -0400
committerArthur Neves <arthurnn@gmail.com>2016-10-28 17:15:23 -0400
commita0a37d9fd3c35f44fa58439fa41b4cdff2d25a98 (patch)
treeb0b66dc49790ea50f888784eb97a622f0854b14e /activerecord/lib
parentaaf561d26cf9a879ff40190b625155015c6225da (diff)
parent9991f14fced25dac3699b473a05cc7a196f9220e (diff)
downloadrails-a0a37d9fd3c35f44fa58439fa41b4cdff2d25a98.tar.gz
rails-a0a37d9fd3c35f44fa58439fa41b4cdff2d25a98.tar.bz2
rails-a0a37d9fd3c35f44fa58439fa41b4cdff2d25a98.zip
Merge PR #19759
Fix for has_and_belongs_to_many & has_many_through associations
Diffstat (limited to 'activerecord/lib')
-rw-r--r--activerecord/lib/active_record/associations/has_many_through_association.rb5
1 files changed, 4 insertions, 1 deletions
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 1f264d325a..8c90aea975 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