diff options
author | Xavier Noria <fxn@hashref.com> | 2012-08-30 06:57:41 +0200 |
---|---|---|
committer | Xavier Noria <fxn@hashref.com> | 2012-08-30 06:58:07 +0200 |
commit | cabab374bfc6c1bd1d783ecc3c674047f17523c6 (patch) | |
tree | 1f3f310c4a340ff50d4496f44ce143d1f9d4c0c1 /activerecord/lib/active_record/transactions.rb | |
parent | f84fc39e2ad4195a7002d92c9bb7ead78f3d57b2 (diff) | |
download | rails-cabab374bfc6c1bd1d783ecc3c674047f17523c6.tar.gz rails-cabab374bfc6c1bd1d783ecc3c674047f17523c6.tar.bz2 rails-cabab374bfc6c1bd1d783ecc3c674047f17523c6.zip |
documents after_(commit|rollback)
Diffstat (limited to 'activerecord/lib/active_record/transactions.rb')
-rw-r--r-- | activerecord/lib/active_record/transactions.rb | 18 |
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] |