collectiveidea/delayed_job — Issue #338: Unable to find custom job in lib/ directory
Author: airblade
Created: 2012-01-24 15:22:33+00:00
State: open

I just deployed a change to my Rails app where instead of calling `@label_sheet.render.delay` I enqueue a custom job with `Delayed::Job.enqueue LabelSheetJob.new(@label_sheet.id)`.

The custom job is in the lib/ directory and looks like:

```ruby
class LabelSheetJob < Struct.new(:label_sheet_id)
def perform
LabelSheet.find(label_Sheet_id).render
end
end
```

This was all working fine the previous way, and works fine the new way in development, but now in production the jobs all fail with `Job failed to load: uninitialized constant LabelSheetJob. Handler: \"--- !ruby/struct:LabelSheetJob \\nlabel_sheet_id: 4721\\n\"`.

When I fire up the Rails console, I can successfully execute `YAML.load handler` where handler is the string from any of the failed jobs, for example `"--- !ruby/struct:EmailJob \nlabel_sheet_id: 4721\n"`.

The workers are running via `rake jobs:work`, managed by Ubuntu's Upstart (config generated by Foreman).

How can I get the workers to find my custom job class in production?

Rails 3.0.9
Delayed Job 2.1.14
Ubuntu 10.04