diff options
author | Rafael França <rafaelmfranca@gmail.com> | 2016-12-29 03:11:57 -0500 |
---|---|---|
committer | GitHub <noreply@github.com> | 2016-12-29 03:11:57 -0500 |
commit | 7ca4b2a76d69d86e1afa92cb0f201f0168815636 (patch) | |
tree | b860fb228b32ec0993aaad15bb517babab3c6b8b /activerecord/lib/active_record | |
parent | 3c90818129e9e295f35c928317c55c111a43d8a9 (diff) | |
parent | 9abf606a79729833fd90f624ed580ad85f3ebadc (diff) | |
download | rails-7ca4b2a76d69d86e1afa92cb0f201f0168815636.tar.gz rails-7ca4b2a76d69d86e1afa92cb0f201f0168815636.tar.bz2 rails-7ca4b2a76d69d86e1afa92cb0f201f0168815636.zip |
Merge pull request #27490 from kamipo/should_not_update_children_when_parent_creation_with_no_reason
Should not update children when the parent creation with no reason
Diffstat (limited to 'activerecord/lib/active_record')
-rw-r--r-- | activerecord/lib/active_record/associations/has_many_through_association.rb | 10 |
1 files changed, 6 insertions, 4 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 0c0aefe3b9..c4a7fe4432 100644 --- a/activerecord/lib/active_record/associations/has_many_through_association.rb +++ b/activerecord/lib/active_record/associations/has_many_through_association.rb @@ -38,10 +38,12 @@ module ActiveRecord def insert_record(record, validate = true, raise = false) ensure_not_nested - if raise - record.save!(validate: validate) - else - return unless record.save(validate: validate) + if record.new_record? || record.has_changes_to_save? + if raise + record.save!(validate: validate) + else + return unless record.save(validate: validate) + end end save_through_record(record) |