-
Notifications
You must be signed in to change notification settings - Fork 336
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Delayed::Job
no longer defined in initializers
#185
Comments
I can work around the issue by adding require 'delayed/backend/active_record'
Delayed::Worker.backend = :active_record at the beginning of the initializers, but that does not feel right. |
I have a similar problem. I'm configuring the delayed_job_active_record/README.md Line 30 in 001b246
This has been working till version 4.1.5 where it produces an error:
Adding the require also resolves it. This does seem related to the change in #172. |
My initializers broke with I've never used one, but I think we could move our initializer to be an |
Yep, this seems to work for me: # config/initializers/delayed_job_extensions.rb
module DelayedJobExtensions
# my customizations
end
- Delayed::Job.prepend DelayedJobExtensions
+ Rails.application.configure do
+ config.after_initialize do
+ Delayed::Job.prepend DelayedJobExtensions
+ end
+ end No errors and my customizations are available in the console. I think you could do something similar. |
I would be nervous simply adding a |
I forgot that change hadn't been released. I need to circle back and update the changelog and probably add more documentation. If you can, wrap what you need to run in an If you can't use require 'delayed/backend/active_record'
Delayed::Worker.backend = :active_record will work, however make sure your initializer runs after any other ActiveRecord configuration initializers. The app initializers are usually run in alphabetical order by filename, so this can usually be accomplished by prefixing your initializer filename with z's like |
Wouldn't something like this be a better way of accomplishing that? ActiveSupport.on_load(:active_record) do
require "delayed/backend/active_record"
Delayed::Worker.backend = :active_record
end |
|
Ugh - yeah, ok. Can't see it happening in production due to eager loads, but I guess it might cause problems in development. |
I ran into this. This is a breaking change in a patch update. I'm not sure if the version numbers are locked to delayed_job but I definitely did not expect this update to break my app. I haven't fully grokked #172 so maybe this is a good path forward but probably some warning and documentation about breaking changes and the pros/cons of different fixes might be warranted. |
I think this may have caused the following in my app when I upgraded from 4.1.4 to 4.1.5 last night: undefined method `where' for Delayed::Job:Class (NoMethodError) Did you mean? when. I'm adding this in case anybody else tries to search the error. The error occurs in an initializer, so I added the block as suggested:
This seems to work (at least Rails will start now). |
This also broke for me in another way (but only in the production environment). I had a small utility class that inherited from
In development it loads fine, but in production this causes the unitialized constant issue. Obviously wrapping this the same as above for initializers doesn't make sense. I use this rarely, so for now I have just removed the class, but others may come across this if inheriting |
Seconding/thirding the comments above. This may well be the ‘right’ change, I haven’t had a chance to properly digest the issue, but making a breaking change in a minor version bump is a bit much! |
There was a breaking change in version 4.1.5 of the gen delayed_job_active_record: collectiveidea/delayed_job_active_record#185 Resulting failure: $ bin/rake db:create db:migrate [...] NameError: undefined method `reserve' for class `Class' /home/travis/build/crowbar/crowbar-core/crowbar_framework/config/initializers/delayed_job_log_silencer.rb:22:in `alias_method' [...]
There was a breaking change in version 4.1.5 of the gem delayed_job_active_record: collectiveidea/delayed_job_active_record#185 Resulting failure: $ bin/rake db:create db:migrate [...] NameError: undefined method `reserve' for class `Class' /home/travis/build/crowbar/crowbar-core/crowbar_framework/config/initializers/delayed_job_log_silencer.rb:22:in `alias_method' [...]
There was a breaking change in version 4.1.5 of the gem delayed_job_active_record: collectiveidea/delayed_job_active_record#185 Resulting failure: $ bin/rake db:create db:migrate [...] NameError: undefined method `reserve' for class `Class' /home/travis/build/crowbar/crowbar-core/crowbar_framework/config/initializers/delayed_job_log_silencer.rb:22:in `alias_method' [...]
There was a breaking change in version 4.1.5 of the gem delayed_job_active_record: collectiveidea/delayed_job_active_record#185 Resulting failure: $ bin/rake db:create db:migrate [...] NameError: undefined method `reserve' for class `Class' /home/travis/build/crowbar/crowbar-core/crowbar_framework/config/initializers/ delayed_job_log_silencer.rb:22:in `alias_method' [...]
There was a breaking change in version 4.1.5 of the gem delayed_job_active_record: collectiveidea/delayed_job_active_record#185 Resulting failure: $ bin/rake db:create db:migrate [...] NameError: undefined method `reserve' for class `Class' /home/travis/build/crowbar/crowbar-core/crowbar_framework/config/initializers/ delayed_job_log_silencer.rb:22:in `alias_method' [...] (cherry picked from commit cb42206)
Don't know if this will be helpful for all of you, but I had an initializer that broke with this update and I was able to find a relatively straightforward resolution as detailed in this issue: #188. |
I'm also seeing this, but with the error:
This happens if you try to use #delay method to delay a method call. I'm adding it to the thread for anyone else searching for the error. |
Ok. I was hoping to come up with a better solution, but didn't, and time got away from me. I have pushed out 4.1.6 which only rolls back the loading change. Using |
We have some initializers in our app that do schedule recurring jobs if they are not scheduled yet (using the delayed_job_cron gem under the hood), so basically code like this:
Since 4.1.5 this results in
NameError: uninitialized constant Delayed::Job
. Looking at the changes it is very probably due to #172 which changed therequire
ing of the relevant code to only happen after initialization.The text was updated successfully, but these errors were encountered: