Skip to content
Browse files

Making sure decrementing only happens when needed, and no explicit ro…

…llback - raising the error again takes care of this.
  • Loading branch information...
1 parent 3b164bf commit 7849d4e565aea6c43d406c3d45a01cb16780a02a @pat committed
Showing with 8 additions and 8 deletions.
  1. +8 −8 lib/after_commit/connection_adapters.rb
View
16 lib/after_commit/connection_adapters.rb
@@ -38,18 +38,18 @@ def commit_db_transaction_with_callback
trigger_after_commit_on_destroy_callbacks
result
rescue
- if committed
- result
- else
- # Need to decrement the transaction pointer before calling
- # rollback... to ensure it is not incremented twice
+ # Need to decrement the transaction pointer before calling
+ # rollback... to ensure it is not incremented twice
+ unless @disable_rollback
decrement_transaction_pointer
- rollback_db_transaction
- increment_transaction_pointer
+ @already_decremented = true
end
+
+ # We still want to raise the exception.
+ raise
ensure
AfterCommit.cleanup(self)
- decrement_transaction_pointer
+ decrement_transaction_pointer unless @already_decremented
end
end
alias_method_chain :commit_db_transaction, :callback

0 comments on commit 7849d4e

Please sign in to comment.
Something went wrong with that request. Please try again.