-
Notifications
You must be signed in to change notification settings - Fork 21.9k
Bring back feature that allows loading external route files: #37892
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
Bring back feature that allows loading external route files: #37892
Conversation
eb1fead
to
0641a56
Compare
@dhh mind to review the documentation to see if it talk about the trade-offs you want to be clear? |
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.
Besides this small nit, this is solid. Good to go!
guides/source/routing.md
Outdated
Breaking up *very* large route file into multiple small ones: | ||
------------------------------------------------------- | ||
|
||
If you work in a large application with hundreds if not thousands of routes, |
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'd say the cut-off is thousands. We have 500+ at Basecamp, and the split is def not worth it there.
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.
We are including different routes on boot, based on some environment variables (like hostname), so for us it's not the total size, but the general separation of different customer routes which is important for us. So there are other factors too to consider, not only the size :)
2d32687
to
e47d9ec
Compare
Thanks for the quick review. This should be good to go |
= This feature existed back in 2012 rails@5e7d6bb but got reverted with the incentive that there was a better approach. After discussions, we agreed that it's a useful feature for apps that have a really large set of routes. Co-authored-by: Yehuda Katz <wycats@gmail.com>
e47d9ec
to
33bf253
Compare
This reverts commit 6acebb3. Usage of this feature did not reveal any improvement in existing apps. Conflicts: actionpack/lib/action_dispatch/routing/mapper.rb guides/source/routing.textile railties/lib/rails/engine.rb railties/lib/rails/paths.rb railties/test/paths_test.rb
Could you maybe add a test which checks if a route concern works, if it's included in a previously loaded concern? Like: # config/routes.rb
Rails.application.routes.draw do
draw(:admin)
draw(:custom1)
draw(:custom2)
end
# config/routes/custom1.rb
namespace :custom1 do
concerns :admin
end
# config/routes/custom2.rb
namespace :custom2 do
concerns :admin
end
# config/routes/admin.rb
concern :admin do
resources :tests
end I'm not sure, but i tried multiple splitting options in the last years, and many of them had a problem with concerns. |
It should work. You could try and report back if it doesn't but this mechanism is the same as defining those concerns in the same file. |
Rails 6.1から標準でroutesファイルを分割できるようになったため。 rails/rails#37892
Thank you so much for re-implementing this! Our application has a very trim, optimized, 1,054-line routes file that I want to split up very badly! Hopefully we can get on Rails 6.1 soon. |
Bring back feature that allows loading external route files:
This feature existed back in 2012
5e7d6bb
but got reverted with the incentive that there was a better approach.
After discussions, we agreed that it's a useful feature for apps
that have a really large set of routes.
Co-authored-by: Yehuda Katz wycats@gmail.com
cc/ @rafaelfranca @etiennebarrie @casperisfine