aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/lib/active_record
diff options
context:
space:
mode:
authorSteve Klabnik <steve@steveklabnik.com>2013-02-13 12:30:01 -0800
committerSteve Klabnik <steve@steveklabnik.com>2013-02-13 12:30:01 -0800
commitf36b80b3e8a1aae9e45af7c82be3917bc6277aa1 (patch)
tree2271c8fc2593bf4afd7158165ac7d5c9a9a66a0a /activerecord/lib/active_record
parent5d58948fe72e3b0422790b8adc0fab7bbf9e6573 (diff)
parentcaabed6c76eea0db99949f34c234ef1b2657392a (diff)
downloadrails-f36b80b3e8a1aae9e45af7c82be3917bc6277aa1.tar.gz
rails-f36b80b3e8a1aae9e45af7c82be3917bc6277aa1.tar.bz2
rails-f36b80b3e8a1aae9e45af7c82be3917bc6277aa1.zip
Merge pull request #9115 from bensie/issue_5802
Don't call after_commit when creating through an association and save fails, fixes #5802
Diffstat (limited to 'activerecord/lib/active_record')
-rw-r--r--activerecord/lib/active_record/transactions.rb5
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