Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

documents after_(commit|rollback)

  • Loading branch information...
commit c584568ae289baa0eb6fa55ab6fe1cb01ccb41e7 1 parent d4b8052
@fxn fxn authored
Showing with 18 additions and 0 deletions.
  1. +18 −0 activerecord/lib/active_record/transactions.rb
View
18 activerecord/lib/active_record/transactions.rb
@@ -208,6 +208,21 @@ def transaction(options = {}, &block)
connection.transaction(options, &block)
end
+ # This callback is called after a record has been created, updated, or destroyed.
+ #
+ # You can specify that the callback should only be fired by a certain action with
+ # the +:on+ option:
+ #
+ # after_commit :do_foo, :on => :create
+ # after_commit :do_bar, :on => :update
+ # after_commit :do_baz, :on => :destroy
+ #
+ # Also, to have the callback fired on create and update, but not on destroy:
+ #
+ # after_commit :do_zoo, :if => :persisted?
+ #
+ # Note that transactional fixtures do not play well with this feature. Please
+ # use the +test_after_commit+ gem to have these hooks fired in tests.
def after_commit(*args, &block)
options = args.last
if options.is_a?(Hash) && options[:on]
@@ -217,6 +232,9 @@ def after_commit(*args, &block)
set_callback(:commit, :after, *args, &block)
end
+ # This callback is called after a create, update, or destroy are rolled back.
+ #
+ # Please check the documentation of +after_commit+ for options.
def after_rollback(*args, &block)
options = args.last
if options.is_a?(Hash) && options[:on]
Please sign in to comment.
Something went wrong with that request. Please try again.