Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I run an ActiveJob in Rails console for debugging?

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?

like image 799
daveomcd Avatar asked Dec 29 '15 21:12

daveomcd


1 Answers

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')
like image 112
Rob Di Marco Avatar answered Oct 21 '22 22:10

Rob Di Marco