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

Eager Load true Causes Routes To Not Be Found #512

Closed
bendangelo opened this issue Oct 6, 2024 · 6 comments
Closed

Eager Load true Causes Routes To Not Be Found #512

bendangelo opened this issue Oct 6, 2024 · 6 comments

Comments

@bendangelo
Copy link

I don't know what the reasoning is but on rails prod "eager_load" is true. And there is code here: https://github.com/TrestleAdmin/trestle/blob/main/lib/trestle/engine.rb#L41

Which in that case will not load the routes. This causes all admin routes to not be found. Is there a missing config?

@spohlenz
Copy link
Member

spohlenz commented Oct 7, 2024

The idea behind disabling that line when eager loading, is that the admin reloading should not be enabled. With eager loading enabled, the admin files are loaded via the Rails autoloader and registered within the Trestle registry. Then the routes are defined for each admin in Trestle's config/routes.rb.

Having said that, I have seen some issues with eager loading and routes in Rails 8, although only in some failing tests, not in any actual apps. I haven't been able to get to the bottom of it fully, although I believe it may be related to rails/rails#52353.

If you are indeed running Rails 8 (or even if not), could you perhaps please upload a test app to GitHub that demonstrates the issue and hopefully I can trace it further.

@bendangelo
Copy link
Author

The idea behind disabling that line when eager loading, is that the admin reloading should not be enabled. With eager loading enabled, the admin files are loaded via the Rails autoloader and registered within the Trestle registry. Then the routes are defined for each admin in Trestle's config/routes.rb.

Having said that, I have seen some issues with eager loading and routes in Rails 8, although only in some failing tests, not in any actual apps. I haven't been able to get to the bottom of it fully, although I believe it may be related to rails/rails#52353.

If you are indeed running Rails 8 (or even if not), could you perhaps please upload a test app to GitHub that demonstrates the issue and hopefully I can trace it further.

Yeah I'm actually on rails 8. I'll have to upload it later but maybe you can try this on a new app with rails 8 beta?

@bendangelo
Copy link
Author

I just tried running this in prod but I can't because I don't have the master key. Can you try running this branch in prod? TrestleAdmin/RailsFlixDemo#32

@spohlenz
Copy link
Member

spohlenz commented Oct 8, 2024

So that particular branch I actually am already running in production (currently preparing it to take over https://demo.trestle.io) and I haven't encountered any issues like this yet.

However the spec failures in TrestleAdmin/trestle-auth#58 seem to be related. If you're able to upload a reproduction, that would definitely be helpful for me to see what might be different.

@spohlenz
Copy link
Member

spohlenz commented Nov 4, 2024

There is now an open PR for rails that appears to fix this issue:

@spohlenz
Copy link
Member

spohlenz commented Nov 5, 2024

Closing as the fix has now been merged into the Rails 8-0-stable branch.

@spohlenz spohlenz closed this as completed Nov 5, 2024
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

No branches or pull requests

2 participants