Rake jobs: work error, uninitialized constant

I am using delayed_job 2.1.0.pre2, and in my lib I have a class called MailingJob (mailing_job.rb) and it has one method called execute. In my controller, I put a new MailingJob in the delayed_job queue, as the dock said. but when I run the "rake jobs: work" command, she always told me that she could not find "MailingJob", do I need to require the mailing_job.rb file? If so, where should I put it? thank you

+3
source share
1 answer

mailing_job.rbshould be in a place where Rails can find and automatically download it. Where do you have this file? If it is not in app/modelsor something like that, it will not find it on its own.

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

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

Source: https://habr.com/ru/post/1769455/


All Articles