You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
First of all, thank you so much for tackling autoloading.
When upgrading a large Rails 5.2 app, I'm encountering the following:
.rbenv/versions/2.5.5/lib/ruby/gems/2.5.0/gems/zeitwerk-2.1.9/lib/zeitwerk/loader.rb:351:in const_get': uninitialized constant ApplicationJob (NameError) Did you mean? ApplicationJob
After enabling the log, it happens when zeitwerk starts loading the jobs folder in the Rails app.
The folder contains a file "application_job.rb" with the following content: class ApplicationJob < ActiveJob::Base queue_as :default end
As this is a quite common pattern, I wonder what the correct way of declaration and usage of such Base Wrapper classes is in order for the autoloading to pick up on it. I also wonder, why the class name is picked up by the typo suggestion below the error output but not Zeitwerk.
Is this a matter of load order, do extensions of Rails Base classes need to be placed in a different namespace or loaded before-hand?
The text was updated successfully, but these errors were encountered:
@byroot thank you for your reply! In a newly created rails 6 app it works fine. I resolved the issue as it was caused by ApplicationJob being referenced in an initializer by moving the code to config.after_initialize.
First of all, thank you so much for tackling autoloading.
When upgrading a large Rails 5.2 app, I'm encountering the following:
.rbenv/versions/2.5.5/lib/ruby/gems/2.5.0/gems/zeitwerk-2.1.9/lib/zeitwerk/loader.rb:351:in const_get': uninitialized constant ApplicationJob (NameError) Did you mean? ApplicationJob
After enabling the log, it happens when zeitwerk starts loading the jobs folder in the Rails app.
The folder contains a file "application_job.rb" with the following content:
class ApplicationJob < ActiveJob::Base queue_as :default end
As this is a quite common pattern, I wonder what the correct way of declaration and usage of such Base Wrapper classes is in order for the autoloading to pick up on it. I also wonder, why the class name is picked up by the typo suggestion below the error output but not Zeitwerk.
Is this a matter of load order, do extensions of Rails Base classes need to be placed in a different namespace or loaded before-hand?
The text was updated successfully, but these errors were encountered: