-
Notifications
You must be signed in to change notification settings - Fork 76
Fix integration with Rails when controllers_path is modified #216
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
base: main
Are you sure you want to change the base?
Conversation
|
@splittingred 👋🏽 can you give this small fix a look? |
| class Railtie < ::Rails::Railtie | ||
| initializer 'gruf.initializer' do |app| | ||
| config.before_configuration do | ||
| config.after_initialize do |
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.
Rails is pretty finicky with initialization order changes between versions. @salmanasiddiqui - I think we're probably going to need to see some proof of life here that this change doesn't break Rails 7.0, 7.1, 7.2, and 8.0 installations.
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.
I think eager load paths are frozen at the point of after_initialize so you won't be able to mutate it
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.
thanks for reviewing this, Im trying to figure if there is a good way to test this railtie. Any suggestions or relevant resources will be greatly appreciated
@zzak - after_initialize is used by gruf-rspec aswell, and I have tested this with Rails 7.1, it updated the autoloader correctly.
https://github.com/bigcommerce/gruf-rspec/blob/main/lib/gruf/rspec/railtie.rb#L25
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.
Have you tried EAGER_LOAD=true?
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.
yes, I did
|
We are working to make a Rails 6.1 app Zeitwerk compatible, and we're running into the same issue as #215 with Is there any chance this PR can get some movement again? |
What? Why?
Fixes #215
The steps to reproduce are described in the above linked issue.
I was thinking that to fix this issue I will have to check
config.eager_loadbutafter_initializeworks fine in both cases.How was it tested?
Created a new rails app locally, followed the steps in the linked issue to reproduce error. Then updated the gem with the change in this PR. That fixed the issue.
I am thinking on how to write a test for this, any help or suggestion would be greatly appreciated. As this depends on how rails app is initialized its kinda hard to test this in isolation. It might be good to have a build step where gruf-demo is checked out and we test this in that?