Created
July 30, 2012 08:07
-
-
Save gnufied/3205621 to your computer and use it in GitHub Desktop.
after_commit_patch.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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