Save 36% for Black Friday! Learn more

Defer Job Enqueues After Transaction Commit in Rails 7.2

August 14, 2024

Track your progress

Sign in to track your progress and access subscription-only lessons.

Log In

Your Teachers

Hi, I'm Chris. I'm the creator of GoRails, Hatchbox.io and Jumpstart. I spend my time creating tutorials and tools to help Ruby on Rails developers build apps better and faster.

Collin Jilbert

Ruby on Rails Developer | Lover of Music | Skateboarder | Proud Papa | Co-editor @therubyradar | Launched @fleur_de_ruby

About This Episode

Enqueuing jobs inside of a database transaction is a common mistake that's now handled for you automatically in Rails 7.2

Notes

Rails uses database transactions in a few places that are invisible to you as the developer. For example, it's easy to use the wrong ActiveRecord callback like after_create that enqueues a job before the new record is committed to the database.

In this lesson, we're going to take a look at this issue in Rails 7.1 and upgrade to 7.2 to see the new configuration option handles this situation for us. It's a much welcomed improvement that is one less thing you have to worry about when reviewing code with your team!

Want to stay up-to-date with Ruby on Rails?

Join 87,110+ developers who get early access to new tutorials, screencasts, articles, and more.

    We care about the protection of your data. Read our Privacy Policy.