diff options
Diffstat (limited to 'activerecord/lib')
-rw-r--r-- | activerecord/lib/active_record/associations/collection_association.rb | 3 | ||||
-rw-r--r-- | activerecord/lib/active_record/associations/has_many_association.rb | 1 |
2 files changed, 2 insertions, 2 deletions
diff --git a/activerecord/lib/active_record/associations/collection_association.rb b/activerecord/lib/active_record/associations/collection_association.rb index 13f77c7d4d..f0cb108136 100644 --- a/activerecord/lib/active_record/associations/collection_association.rb +++ b/activerecord/lib/active_record/associations/collection_association.rb @@ -307,6 +307,8 @@ module ActiveRecord target << record end + set_inverse_instance(record) + yield(record) if block_given? rescue if index @@ -319,7 +321,6 @@ module ActiveRecord end callback(:after_add, record) unless skip_callbacks - set_inverse_instance(record) record end diff --git a/activerecord/lib/active_record/associations/has_many_association.rb b/activerecord/lib/active_record/associations/has_many_association.rb index 742cd25509..482970cfea 100644 --- a/activerecord/lib/active_record/associations/has_many_association.rb +++ b/activerecord/lib/active_record/associations/has_many_association.rb @@ -38,7 +38,6 @@ module ActiveRecord def insert_record(record, validate = true, raise = false) set_owner_attributes(record) - set_inverse_instance(record) if raise record.save!(validate: validate) |