Skip to content

Instantly share code, notes, and snippets.

@gnufied
Created April 25, 2012 15:52
Show Gist options
  • Save gnufied/2490823 to your computer and use it in GitHub Desktop.
Save gnufied/2490823 to your computer and use it in GitHub Desktop.
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