Skip to content

Instantly share code, notes, and snippets.

@craigw
Created June 18, 2009 16:46
Show Gist options
  • Save craigw/131997 to your computer and use it in GitHub Desktop.
Save craigw/131997 to your computer and use it in GitHub Desktop.
# This playing about lead to the following plugin:
# http://github.com/craigw/callback_after_commit/tree/master
# use that instead.
module TransactionCommitCallback
def self.included(base)
base.send(:alias_method, :transaction_without_callbacks,
:transaction)
end
def transaction(*args)
transaction_without_callbacks(*args)
run_callbacks :after_commit
end
end
ActiveRecord::Base.send(:define_callbacks, :after_commit)
ActiveRecord::ConnectionAdapters::DatabaseStatements.send(:include, TransactionCommitCallback)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment