File tree Expand file tree Collapse file tree 1 file changed +21
-0
lines changed
activerecord/lib/active_record Expand file tree Collapse file tree 1 file changed +21
-0
lines changed Original file line number Diff line number Diff line change @@ -188,6 +188,27 @@ module Transactions
188
188
# #after_commit is a good spot to put in a hook to clearing a cache since clearing it from
189
189
# within a transaction could trigger the cache to be regenerated before the database is updated.
190
190
#
191
+ # ==== NOTE: Callbacks are deduplicated per callback by filter.
192
+ #
193
+ # Trying to define multiple callbacks with the same filter will result in a single callback being run.
194
+ #
195
+ # For example:
196
+ #
197
+ # after_commit :do_something
198
+ # after_commit :do_something # only the last one will be called
199
+ #
200
+ # This applies to all variations of <tt>after_*_commit</tt> callbacks as well.
201
+ #
202
+ # after_commit :do_something
203
+ # after_create_commit :do_something
204
+ # after_save_commit :do_something
205
+ #
206
+ # It is recommended to use the +on:+ option to specify when the callback should be run.
207
+ #
208
+ # after_commit :do_something, on: [:create, :update]
209
+ #
210
+ # This is equivalent to using +after_create_commit+ and +after_update_commit+, but will not be deduplicated.
211
+ #
191
212
# === Caveats
192
213
#
193
214
# If you're on MySQL, then do not use Data Definition Language (DDL) operations in nested
You can’t perform that action at this time.
0 commit comments