method

after_commit

after_commit(*args, &block)
public

No documentation available.

# File activerecord/lib/active_record/transactions.rb, line 207
      def after_commit(*args, &block)
        options = args.last
        if options.is_a?(Hash) && options[:on]
          options[:if] = Array.wrap(options[:if])
          options[:if] << "transaction_include_action?(:#{options[:on]})"
        end
        set_callback(:commit, :after, *args, &block)
      end

2Notes

Bug - this is not working as documented

beagile · Oct 11, 20132 thanks

The stacking of several after_commit lines is not working.
The last line overwrites the ones before.

Using an array for the :on options is also not working.

For details look here:
http://github.com/rails/rails/issues/988#issuecomment-12653474

Exceptions raised within are ignored.

DarkFox · Mar 5, 2013

From http://guides.rubyonrails.org/active_record_validations_callbacks.html

The after_commit and after_rollback callbacks are guaranteed to be called for all models created, updated, or destroyed within a transaction block. If any exceptions are raised within one of these callbacks, they will be ignored so that they don’t interfere with the other callbacks. As such, if your callback code could raise an exception, you’ll need to rescue it and handle it appropriately within the callback.