From c957f5f609d59e2575a767e9213856374bab5677 Mon Sep 17 00:00:00 2001 From: Rob Sanheim Date: Fri, 11 Jul 2014 20:31:37 -0700 Subject: [PATCH] only _run_commit_callbacks when destroyed or persisted: should fix issues with commit callbacks getting called when the record is not persisted (yet) in a inner transaction or due to some other edge case. see also https://github.com/rails/rails/commit/caabed6c76eea0db99949f34c234ef1b2657392a Conflicts: activerecord/lib/active_record/transactions.rb --- activerecord/lib/active_record/transactions.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/activerecord/lib/active_record/transactions.rb b/activerecord/lib/active_record/transactions.rb index a00c80b269..1227741b49 100644 --- a/activerecord/lib/active_record/transactions.rb +++ b/activerecord/lib/active_record/transactions.rb @@ -278,7 +278,7 @@ module ActiveRecord # Call the after_commit callbacks def committed! #:nodoc: - run_callbacks :commit + run_callbacks :commit if destroyed? || persisted? ensure @_start_transaction_state.clear end