rake jobs:work error, uninitialized constant

孤者浪人 提交于 2019-12-07 16:07:16

问题


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!


回答1:


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 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"


来源:https://stackoverflow.com/questions/3929232/rake-jobswork-error-uninitialized-constant

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!