views:

30

answers:

1

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  A: 

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"
tfe
good clue,i put the "mailing_job.rb" into my RAILSAPP/lib directory, i thought it would be loaded automatically,would the lib directory load auto when the rails run?
29decibel
No, `lib` isn't in the load paths by default. You could add an initializer to require your things from lib though.
tfe
great thanks!! i will try it later,thanks
29decibel
thanks,it works
29decibel