Skip to content

Commit 30753c1

Browse files
authored
Merge pull request rails#51489 from p8/guides/improve-enqueue-after-transaction-commit-documentation
Fix documentation for `enqueue_after_transaction_commit`
2 parents 539fcc5 + 97e2e93 commit 30753c1

File tree

2 files changed

+17
-11
lines changed

2 files changed

+17
-11
lines changed

guides/source/configuring.md

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2768,9 +2768,13 @@ end
27682768
Controls whether Active Job's `#perform_later` and similar methods automatically defer
27692769
the job queuing to after the current Active Record transaction is committed.
27702770
2771-
It can be set to `:never` to never defer the enqueue, to `:always` always defer
2772-
the enqueue, or to `:default` to let the queue adapter define if it should be defered
2773-
or not. Active Job backends that use the same database than Active Record as a queue,
2771+
It can be set to:
2772+
2773+
* `:never` - Never defer the enqueue.
2774+
* `:always` - Always defer the enqueue.
2775+
* `:default` - Let the queue adapter define the behaviour.
2776+
2777+
Active Job backends that use the same database as Active Record as a queue,
27742778
should generally prevent the deferring, and others should allow it.
27752779
27762780
Example:
@@ -2783,8 +2787,8 @@ end
27832787
```
27842788
27852789
In this example, if the configuration is set to `:never`, the job will
2786-
be enqueued immediately, even thought the `Topic` hasn't been committed yet.
2787-
Because of this, if the job is picked up almost emmediately, or if the
2790+
be enqueued immediately, even though the `Topic` hasn't been committed yet.
2791+
Because of this, if the job is picked up almost immediately, or if the
27882792
transaction doesn't succeed for some reason, the job will fail to find this
27892793
topic in the database.
27902794

railties/lib/rails/generators/rails/app/templates/config/initializers/new_framework_defaults_7_2.rb.tt

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -19,12 +19,14 @@
1919
# NewTopicNotificationJob.perform_later(topic)
2020
# end
2121
#
22-
# In this example, if `enqueue_after_transaction_commit` is `false` the job will
23-
# be enqueued immediately, even thought the `Topic` hasn't been committed yet.
24-
# Because of this, if the job is picked up almost emmediately, it will fail to
25-
# find this topic in the databse.
26-
# With `enqueue_after_transaction_commit = true`, the job will be actually enqueued
27-
# after the transaction has been committed.
22+
# In this example, if the configuration is set to `:never`, the job will
23+
# be enqueued immediately, even though the `Topic` hasn't been committed yet.
24+
# Because of this, if the job is picked up almost immediately, or if the
25+
# transaction doesn't succeed for some reason, the job will fail to find this
26+
# topic in the database.
27+
#
28+
# If `enqueue_after_transaction_commit` is set to `:default`, the queue adapter
29+
# will define the behaviour.
2830
#
2931
# Note: Active Job backends can disable this feature. This is generally used by
3032
# backends that use the same database than Active Record as a queue, hence they

0 commit comments

Comments
 (0)