diff options
author | Arthur Neves <arthurnn@gmail.com> | 2016-10-28 17:15:23 -0400 |
---|---|---|
committer | Arthur Neves <arthurnn@gmail.com> | 2016-10-28 17:15:23 -0400 |
commit | a0a37d9fd3c35f44fa58439fa41b4cdff2d25a98 (patch) | |
tree | b0b66dc49790ea50f888784eb97a622f0854b14e /activerecord/lib | |
parent | aaf561d26cf9a879ff40190b625155015c6225da (diff) | |
parent | 9991f14fced25dac3699b473a05cc7a196f9220e (diff) | |
download | rails-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.rb | 5 |
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 |