I currently have an ActiveJob that I've created and use Sidekiq to queue it. I'm wanting to debug the job, but for me to see any messages I program into it I have to check my log files. I feel like it would be more convenient to be able to see my puts
messages in my job in the Rails Console. When I run the perform_later
method though in rails console it just queues the job up and I never see the messages in console. Is there a way to make it where I will see them in the console?
Asked
Active
Viewed 2.6k times
17

daveomcd
- 6,367
- 14
- 83
- 137
-
I just open a second console and tails the log... interested to see if there is a better answer! – Mitch VanDuyn Dec 29 '15 at 21:37
4 Answers
34
You can run a job with perform_now
.
For example...
class Foo < ActiveJob::Base
def perform(arg1)
puts "Hello #{arg1}"
end
end
Foo.perform_now('world')

Rob Di Marco
- 43,054
- 9
- 66
- 56
10
You can temporarily set your queue adapter to inline.
Right now your code in application.rb
will 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 run your job inline, and you should see the results in the console.

Amar H-V
- 1,316
- 3
- 20
- 33
0
There is a configuration line you can add in development.rb
require 'sidekiq/testing/inline'
This should enable inline testing for development.

Lomefin
- 1,173
- 12
- 43