Skip to content

Instantly share code, notes, and snippets.

@gnufied
Created July 30, 2012 08:07
Show Gist options
  • Save gnufied/3205621 to your computer and use it in GitHub Desktop.
Save gnufied/3205621 to your computer and use it in GitHub Desktop.
after_commit_patch.rb
#WARNING do not load this file in environments other than test
module AfterCommitPatch
def transaction(options = {})
rolled_back = false
return_value = nil
begin
return_value = super
rescue ActiveRecord::Rollback => e
puts e.message
puts e.backtrace
rolled_back = true
end
if !rolled_back && open_transactions == 1
commit_transaction_records
end
return_value
end
end
require "lib/patches/after_commit_patch"
ActiveRecord::ConnectionAdapters::AbstractAdapter.send(:include, AfterCommitPatch)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment