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

Fix integration with Rails when controllers_path is modified #216

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

salmanasiddiqui
Copy link

@salmanasiddiqui salmanasiddiqui commented Nov 9, 2024

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_load but after_initialize works 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?

@salmanasiddiqui salmanasiddiqui marked this pull request as ready for review November 9, 2024 20:20
@salmanasiddiqui
Copy link
Author

@splittingred 👋🏽 can you give this small fix a look?

@@ -23,10 +23,10 @@ module Rails
#
class Railtie < ::Rails::Railtie
initializer 'gruf.initializer' do |app|
config.before_configuration do
config.after_initialize do
Copy link
Member

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.

Copy link

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

Copy link
Author

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

Copy link

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?

Copy link
Author

Choose a reason for hiding this comment

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

yes, I did

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

Successfully merging this pull request may close these issues.

Gruf.controllers_path config breaks integration with Rails
3 participants