aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/lib/active_record/transactions.rb
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:57:41 +0200
commitc584568ae289baa0eb6fa55ab6fe1cb01ccb41e7 (patch)
treefbe460e2b118285972a059341892d93af81fcf1e /activerecord/lib/active_record/transactions.rb
parentd4b8052e04d2e01f36d008e6e9d05097b6fe6184 (diff)
downloadrails-c584568ae289baa0eb6fa55ab6fe1cb01ccb41e7.tar.gz
rails-c584568ae289baa0eb6fa55ab6fe1cb01ccb41e7.tar.bz2
rails-c584568ae289baa0eb6fa55ab6fe1cb01ccb41e7.zip
documents after_(commit|rollback)
Diffstat (limited to 'activerecord/lib/active_record/transactions.rb')
-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 8acbc08e09..09318879d5 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]