Skip to content
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

Add lib/controllers/ENGINE to the autoload_paths #78

Merged

Conversation

DanielePalombo
Copy link
Contributor

@DanielePalombo DanielePalombo commented Jun 7, 2023

Summary

SolidusSupport added lib/decorators/#{engine} to the autoload_paths, but there are no other autoloaded_paths for lib. This is a problem when the decorator tries to decorate an existing class, because it's not loaded yet.

A real example, happened on solidus_social, because it decorates a controller defined on solidus_auth_devise.

Checklist

Check out our PR guidelines for more details.

The following are mandatory for all PRs:

The following are not always needed:

  • 📖 I have updated the README to account for my changes.
  • 📑 I have documented new code with YARD.
  • 🛣️ I have opened a PR to update the guides.
  • ✅ I have added automated tests to cover my changes.
  • 📸 I have attached screenshots to demo visual changes.

@DanielePalombo
Copy link
Contributor Author

@elia, this is the ticket we have investigated today.

@elia elia requested a review from kennyadsl June 9, 2023 15:03
@kennyadsl
Copy link
Member

@DanielePalombo I'm not sure to understand the problem: are you decorating a controller that has been defined in the same engine? I'm sure I'm missing something, can you make a rough example?

@elia
Copy link
Member

elia commented Jun 9, 2023

@kennyadsl as a result of the investigation we discovered that with Rails 5.2 and Solidus 3 the RegistrationController defined by solidus_auth_devise was not autoloaded correctly and another extension (solidus_social) attempting to decorate that controller was not finding it.

The decorator paths were added to the autoload paths here but the same wasn't done for lib/controllers.

@kennyadsl
Copy link
Member

Ah, so, so we are talking about decorating controllers defined in other extensions, which are not autoloaded, makes sense now!

@DanielePalombo
Copy link
Contributor Author

Thank you @elia for the explaination

Copy link
Member

@kennyadsl kennyadsl left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Left a suggestion to improve readability, up to you!

SolidusSupport added `lib/decorators/#{engine}` to the autoload_paths,
but there are no other autoloaded_paths for `lib`.
This is a problem when the decorator tries to decorates an existing
class, because it's not loaded yet.
@DanielePalombo DanielePalombo force-pushed the dp/fix-autoload-paths-engines branch from 433eadd to 7a03048 Compare June 9, 2023 15:48
@DanielePalombo DanielePalombo requested a review from kennyadsl June 9, 2023 15:49
@kennyadsl kennyadsl merged commit 17e8718 into solidusio:master Jun 9, 2023
@kennyadsl
Copy link
Member

Merged, do we need a new version released?

@DanielePalombo DanielePalombo deleted the dp/fix-autoload-paths-engines branch June 9, 2023 15:52
@DanielePalombo
Copy link
Contributor Author

Yes, please!

@kennyadsl
Copy link
Member

kennyadsl commented Jun 9, 2023

@DanielePalombo @elia done!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants