Created
April 25, 2012 15:52
-
-
Save gnufied/2490823 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
module AfterCommitPatch | |
def transaction(options = {}) | |
rolled_back = false | |
begin | |
super | |
rescue ActiveRecord::Rollback => e | |
rolled_back = true | |
end | |
invoke_commit_objects unless rolled_back | |
end | |
def invoke_commit_objects | |
records = @_current_transaction_records.flatten | |
@_current_transaction_records.clear | |
unless records.blank? | |
records.uniq.each do |record| | |
begin | |
record.committed! | |
rescue Exception => e | |
record.logger.error(e) if record.respond_to?(:logger) && record.logger | |
end | |
end | |
end | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment