Fix integration with Rails when controllers_path is modified#216
Fix integration with Rails when controllers_path is modified#216salmanasiddiqui wants to merge 1 commit intobigcommerce:mainfrom
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.
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.
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.
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.
Have you tried EAGER_LOAD=true?
|
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?