Search code examples
ruby-on-railsrufus-scheduler

Best way to not run rufus-scheduler when starting a rails console


I use rufus-scheduler to run some periodic tasks, but they are extremely annoying to have in the rails console when I just want to test things. Is there an easy way to stop all rufus-scheduler tasks when starting a console automatically?

In the code that starts the scheduler if i can check that i am just in a rails console I can not run them, or if there is a way to run some callbacks when the console starts I can also shut them down there.

Thanks


Solution

  • Based on Rails check if IRB console or webpage:

    unless self.private_methods.include? 'irb_binding'
      #put your rufus scheduling here
    end