启动Rails控制台时不运行rufus-scheduler的最佳方法 [英] Best way to not run rufus-scheduler when starting a rails console

查看:86
本文介绍了启动Rails控制台时不运行rufus-scheduler的最佳方法的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用rufus-scheduler运行一些定期任务,但是当我只想测试事物时,它们在Rails控制台中却非常烦人.自动启动控制台时,有一种简单的方法来停止所有rufus-scheduler任务吗?

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?

在启动调度程序的代码中,如果我可以检查自己是否在Rails控制台中,则我无法运行它们,或者如果在控制台启动时,有一种方法可以运行一些回调,则也可以在其中关闭它们.

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.

谢谢

推荐答案

基于检查是否是IRB控制台或网页:

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

这篇关于启动Rails控制台时不运行rufus-scheduler的最佳方法的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆