{"action":"opened","issue":{"url":"https://api.github.com/repos/collectiveidea/delayed_job/issues/779","labels_url":"https://api.github.com/repos/collectiveidea/delayed_job/issues/779/labels{/name}","comments_url":"https://api.github.com/repos/collectiveidea/delayed_job/issues/779/comments","events_url":"https://api.github.com/repos/collectiveidea/delayed_job/issues/779/events","html_url":"https://github.com/collectiveidea/delayed_job/issues/779","id":57486899,"number":779,"title":"Job failed to load: undefined class/module User::Identity","user":{"login":"bbrealnex","id":8922946,"avatar_url":"https://avatars.githubusercontent.com/u/8922946?v=3","gravatar_id":"","url":"https://api.github.com/users/bbrealnex","html_url":"https://github.com/bbrealnex","followers_url":"https://api.github.com/users/bbrealnex/followers","following_url":"https://api.github.com/users/bbrealnex/following{/other_user}","gists_url":"https://api.github.com/users/bbrealnex/gists{/gist_id}","starred_url":"https://api.github.com/users/bbrealnex/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/bbrealnex/subscriptions","organizations_url":"https://api.github.com/users/bbrealnex/orgs","repos_url":"https://api.github.com/users/bbrealnex/repos","events_url":"https://api.github.com/users/bbrealnex/events{/privacy}","received_events_url":"https://api.github.com/users/bbrealnex/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":0,"created_at":"2015-02-12T16:53:33Z","updated_at":"2015-02-12T16:53:33Z","closed_at":null,"body":"This is driving me batty, mostly due to the random nature of it.\r\n\r\nWe are running Rails 4.1 and I have a simple ActiveResource (not ActiveRecord) object called \"User\" with a method called \"update_metadatas\" (it takes a json hash as a param). So I'll load up a User object (let's call it u) and then call u.update_metadatas(data). Works great. However, when I do u.delay.update_metadatas(data), things go screwy.\r\n\r\nSeemingly depending on the time or day or direction of the wind (ok not really), the above job will immediately fail with:\r\n\r\nJob failed to load: undefined class/module User::Identity\r\n\r\nThe errors aren't that revealing.\r\n\r\nSometimes it will work great with no problems. This behavior happens on both development (local workstation) and production (Heroku).\r\n\r\nMy guess is that this is a preloading issue . . . i.e., it seems random only because it is affected by when the worker runs (before or after when the rest of the application loads). For example I'll have all the jobs fail for a 2 hour period, and then they'll start working again. I tried the suggestion about turning off config.threadsafe! in production.rb for rake tasks, but that doesn't work for Rails 4.1. I tried the suggestion of adding an initializer like \"require 'user'\", but that didn't help.\r\n\r\nANY ideas?\r\n\r\nP.S. I also run Puma, not sure if that matters (I don't believe Puma is used for the rake tasks though)."}}