-
-
Notifications
You must be signed in to change notification settings - Fork 23
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
Don't skip the first namespace for controller paths #80
Conversation
@DanielePalombo @mamhoff can you confirm if fixes the issue for your projects? |
@@ -110,7 +110,7 @@ def enable_solidus_engine_support(engine) | |||
decorators_path = root.join("lib/decorators/#{engine}") | |||
controllers_path = root.join("lib/controllers/#{engine}") | |||
config.autoload_paths += decorators_path.glob('*') | |||
config.autoload_paths += controllers_path.glob('*') | |||
config.autoload_paths << controllers_path if controller_path.exist? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This works, but should the line 112 (just above) not receive the same treatment?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good call, I'd expect that folder to have an additional layer and be similar to app/
in that regard, eg. lib/decorators/solidus_foo/models/spree/product/my_decorator.rb
lib/decorators/frontend/models/spree/product/my_decorator.rb
An example from auth devise:
lib/decorators/frontend/controllers/spree/checkout_controller_decorator.rb
Autoload paths are meant to list autoload roots and not the first level of the namespace. E.g. having the following controller in lib/controllers/solidus_foo: lib/controllers/solidus_foo/spree/my_controller.rb The autoload will be triggered by a constant reference to `Spree::MyController` targeting `spree/my_controller.rb` inside `lib/controllers/solidus_foo/`. This means the autoload path needs to be `lib/controllers/solidus_foo/`.
36d8d26
to
45f1a6a
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM.
Released in 0.9.3 |
lib
stopped working #79Summary
Autoload paths are meant to list autoload roots and not the first level of the namespace.
E.g. having the following controller in lib/controllers/solidus_foo:
The autoload will be triggered by a constant reference to
Spree::MyController
targetingspree/my_controller.rb
insidelib/controllers/solidus_foo/
. This means the autoload path needs to belib/controllers/solidus_foo/
.See also https://edgeguides.rubyonrails.org/classic_to_zeitwerk_howto.html#globs-in-config-autoload-paths
Checklist
Check out our PR guidelines for more details.
The following are mandatory for all PRs:
The following are not always needed: