耙工作:工作错误,未初始化的常数 [英] rake jobs:work error, uninitialized constant

查看:72
本文介绍了耙工作:工作错误,未初始化的常数的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用的是delay_job 2.1.0.pre2,
,在我的lib中,我有一个名为MailingJob(mailing_job.rb)的类,它有一个名为perform的方法。
在我的控制器中,我将新的MailingJob对象放入doc所说的delay_job队列中。
,但是当我运行 rake jobs:work命令时,它总是告诉我找不到 MailingJob,是否需要要求mailing_job.rb文件?如果是,我应该放在哪里?
谢谢!

i am using delayed_job 2.1.0.pre2, and in my lib i have a class which named MailingJob(mailing_job.rb),and it has one method named perform. In my controller , i put a new MailingJob object in my delayed_job queue as the doc said. but when i run the "rake jobs:work" command,it always told me that it can't find "MailingJob", is it necessary to require the mailing_job.rb file?if yes,where should i put this? thanks!

推荐答案

mailing_job.rb 必须位于Rails可以找到的地方并自动加载。你在哪里有那个文件?除非它在 app / models 中或类似的东西中,否则它不会自行找到它。

mailing_job.rb must be in a place where Rails can find and auto-load it. Where do you have that file? Unless it's in app/models or something like that, it won't find it on its own.

I在 app / jobs 中有我的工作,但这行得通,因为我将该路径添加到 environment.rb Rails :: Initializer.run 块:

I have my jobs in app/jobs but this works because I added that path to the Rails load paths in the environment.rb Rails::Initializer.run block:

config.load_paths << "#{Rails.root}/app/jobs"

这篇关于耙工作:工作错误,未初始化的常数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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