Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Tree: c4ad250c1c
Fetching contributors…

Cannot retrieve contributors at this time

44 lines (28 sloc) 1.93 kB

after_commit

An ActiveRecord/Rails library to add after_commit callback. These callback is focused on the transactions, instead of specific model actions. This is especially important with cache expiry. g

Installation

gem install after_commit --source http://gemcutter.org

Usage

The following callbacks are provided:

  • after_commit
  • (… others removed in this fork)

You can use these just like you would any other callback:

class Article < ActiveRecord::Base
  after_commit :method_to_call_after_commit
  
  # ...
  
  private
  
  def method_to_call_after_commit
    # Do something knowing that the transaction is committed.
  end
end

Credits

This code first appeared in a blog post by Eli Miller, and was then included in Thinking Sphinx by Pat Allan, with modifications from Joost Hietbrink. The code was then put on GitHub as a plugin by Nick Muerdter, and many people forked and added their own contributions.

This version (maintained by Pat Allan) includes the following patches:

Jump to Line
Something went wrong with that request. Please try again.