adds commit_callback to ActiveRecord::Base, usually you’ll want to call it from an after_save hook. For Example:
after_save :send_some_message def send_some_message self.commit_callback do #do the real message sending now that we’re sure self has been committed to the DB end end
if your tests
use_transactional_fixtures = true
then you might find it useful to put this in your setup CommitCallback.adapt_for_transactional_test!(ActiveRecord::Base.connection) Copyright © 2009 3M. All rights reserved. Released under the MIT license.
Authored by Jacob Burkhart.