RubyFlow The Ruby and Rails community linklog

×

The Ruby and Rails community linklog

Made a library? Written a blog post? Found a useful tutorial? Share it with the Ruby community here or just enjoy what everyone else has found!

Run it in background job, after commit, from Service Object

There is this problem that when you schedule a background job from inside of a running database transaction, the background job can kick in before the transaction is commited. Then the job can’t find the data that it expects to already be there, in database. How do we solve this issue? Let’s schedule the job from Service Object after db commit.

.

It also includes a small dive in into how Active Record tracks after_commit hooks.

Post a comment

You can use basic HTML markup (e.g. <a>) or Markdown.

As you are not logged in, you will be
directed via GitHub to signup or sign in