How to run ActiveJob console in Rails for debugging?

I currently have an ActiveJob that I have created and am using Sidekiq for its lineup. I want to debug work, but in order to view any messages that I program, I need to check my log files. I feel that it would be more convenient to see my posts putsin my work in the Rails Console. When I run the method perform_later, although in the rails console it just pauses and I never see the messages in the console. Is there a way to do this when I see them in the console?

+4
source share
2 answers

You can start the task with perform_now.

For example...

class Foo < ActiveJob::Base
  def perform(arg1)
    puts "Hello #{arg1}"
  end
end

Foo.perform_now('world')
+11
source

You can temporarily install a queue adapter in a string.

Now your code in application.rbwill look something like this:

Rails.application.config.active_job.queue_adapter = :sidekiq

Just comment out the line

# Rails.application.config.active_job.queue_adapter = :sidekiq

This will start your work on line and you will see the results in the console.

+3
source

Source: https://habr.com/ru/post/1622141/


All Articles