Skip to content

Instantly share code, notes, and snippets.

@egze
Forked from gnufied/after_commit_patch.rb
Created August 21, 2012 18:22
Show Gist options
  • Save egze/3418135 to your computer and use it in GitHub Desktop.
Save egze/3418135 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