aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord
diff options
context:
space:
mode:
authorXavier Noria <fxn@hashref.com>2012-08-30 06:57:41 +0200
committerXavier Noria <fxn@hashref.com>2012-08-30 06:58:07 +0200
commitcabab374bfc6c1bd1d783ecc3c674047f17523c6 (patch)
tree1f3f310c4a340ff50d4496f44ce143d1f9d4c0c1 /activerecord
parentf84fc39e2ad4195a7002d92c9bb7ead78f3d57b2 (diff)
downloadrails-cabab374bfc6c1bd1d783ecc3c674047f17523c6.tar.gz
rails-cabab374bfc6c1bd1d783ecc3c674047f17523c6.tar.bz2
rails-cabab374bfc6c1bd1d783ecc3c674047f17523c6.zip
documents after_(commit|rollback)
Diffstat (limited to 'activerecord')
-rw-r--r--activerecord/lib/active_record/transactions.rb18
1 files changed, 18 insertions, 0 deletions
diff --git a/activerecord/lib/active_record/transactions.rb b/activerecord/lib/active_record/transactions.rb
index 98569aa307..1b14df70e0 100644
--- a/activerecord/lib/active_record/transactions.rb
+++ b/activerecord/lib/active_record/transactions.rb
@@ -208,6 +208,21 @@ module ActiveRecord
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 @@ module ActiveRecord
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]