diff options
author | James Miller <bensie@gmail.com> | 2013-02-13 12:27:06 -0800 |
---|---|---|
committer | James Miller <bensie@gmail.com> | 2013-02-13 12:27:06 -0800 |
commit | caabed6c76eea0db99949f34c234ef1b2657392a (patch) | |
tree | 2271c8fc2593bf4afd7158165ac7d5c9a9a66a0a /activerecord/lib/active_record/transactions.rb | |
parent | 5d58948fe72e3b0422790b8adc0fab7bbf9e6573 (diff) | |
download | rails-caabed6c76eea0db99949f34c234ef1b2657392a.tar.gz rails-caabed6c76eea0db99949f34c234ef1b2657392a.tar.bz2 rails-caabed6c76eea0db99949f34c234ef1b2657392a.zip |
Don't call after_commit when creating through an association and save fails, fixes #5802
Diffstat (limited to 'activerecord/lib/active_record/transactions.rb')
-rw-r--r-- | activerecord/lib/active_record/transactions.rb | 5 |
1 files changed, 4 insertions, 1 deletions
diff --git a/activerecord/lib/active_record/transactions.rb b/activerecord/lib/active_record/transactions.rb index 4a608e4f7b..4b7a388dc7 100644 --- a/activerecord/lib/active_record/transactions.rb +++ b/activerecord/lib/active_record/transactions.rb @@ -286,8 +286,11 @@ module ActiveRecord end # Call the after_commit callbacks + # + # Ensure that it is not called if the object was never persisted (failed create), + # but call it after the commit of a destroyed object def committed! #:nodoc: - run_callbacks :commit + run_callbacks :commit if destroyed? || persisted? ensure clear_transaction_record_state end |