Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I turn all my 'perform_later's into 'perform_now's locally?

I'm working on a product that calls of perform_later jobs. This works for our product in production because we have a series of workers who will run all the jobs.

But, when I'm using the app locally, I don't have access to these workers, and I'd like to change all the perform_laters into perform_nows only when I use the app locally.

What's the best way to do this? One idea I had was to add something in my env file that would add a variable to make all perform_laters into perform_nows -- but I'm not sure what a flag or variable like that would look like.

Ideas?

like image 866
acoravos Avatar asked Jul 06 '16 20:07

acoravos


1 Answers

The clean solution is to change the adapter in development environment.

In your /config/environments/development.rb you need to add:

Rails.application.configure do
  config.active_job.queue_adapter = :inline
end

"When enqueueing jobs with the Inline adapter the job will be executed immediately."

like image 64
Leantraxxx Avatar answered Oct 26 '22 23:10

Leantraxxx