Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Revert "Allow loading external route files from the router"
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
- Loading branch information
Showing
10 changed files
with
6 additions
and
149 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
5e7d6bb
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.
@josevalim What do you mean by "Usage of this feature did not reveal any improvement in existing apps."? Compared to doing it manually, without special framework support?
I've found it useful to split routes into multiple files on larger projects, but IIRC it was easy enough with just multiple
My::Application.routes.draw
orinstance_eval
or something.5e7d6bb
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.
This was reverted in favor of https://github.com/rails/routing_concerns, that we think is a better approach.
5e7d6bb
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.
@rafaelfranca Thanks! I don't see from the README how
routing_concerns
does anything to help split up routes, though – how would you go about that?5e7d6bb
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.
The point of 'splitting up routes' was to make the routes file easier to read.
routing_concerns
will (hopefully) DRY up your routes so that you don't need to split them up anymore.5e7d6bb
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.
@steveklabnik Alright, thanks!
5e7d6bb
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.
But Rails makes possible to split much: locales, migrations... It's useful for spliting-up-by-components very much!
5e7d6bb
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.
@steveklabnik amn't I right (see previous message)?
5e7d6bb
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 don't know if you're right or not. Personally, I never tried this feature. @dhh didn't find it very helpful.
5e7d6bb
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.
Are there any examples of this new approach to defining multiple routes? Rails 4 docs make it look like concerns can only be used to modify existing routes...?
5e7d6bb
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.
Actually concern routes are provided for DRY concerns, this is not really an alternative to the reverted patch here. I guess there is no equivalent at the time being but I may be wrong. It looks like this is not so hard to implement such feature inside your application.
5e7d6bb
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.
5e7d6bb
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.
Agreed, especially if the language already supports it, no need to try and over-systemize it. I think I've got something figured out.
5e7d6bb
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 find this really useful, so I followed the gist linked to here to get the basic functionality working.
The problem I'm running into now is the lack of autoloader support. I see in this commit that a bunch of integration points had to be made to autoload the files in
config/routes/*.rb
. Does Rails 4 have some cool API I don't know about that will allow me to affect the same changes without monkeypatching?Thanks!
5e7d6bb
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.
Splitting a large routes.rb file in smaller parts can be very helpful, specially if you have totally independent routes. A classical example would be an app with many different user types (admin, members, guests, etc). Concerns could even be shared between all of them. Anyways, concerns helps a lot on code reusability, but not necessarily on code readability. Anyway the need for native support depends on the eye of the beholder
5e7d6bb
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.
From my point of view you removed a really great feature.. Concerns are nice, but if you really want to seperate big route sets (like for components: apis, backend, frontend1, frontend2) you are now lost. I've tried the
instance_eval
solution, but this doesn't reload my routes in development..I would be really happy if you could bring back this functionality.
Edit:
I'm now going with this approach, but it's still not reloading in my dev environment if I change something (see http://stackoverflow.com/a/34798146/74264):
5e7d6bb
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.
@lichtamberg did you try the answer below ? This is how its been done in Gitlab (see https://gitlab.com/gitlab-org/gitlab-ce/blob/master/config/initializers/routing_draw.rb) works like charm :)
5e7d6bb
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 had reload issue similar to @lichtamberg .
And I re-implemented
Rails::Application#routes_reloader
to solve this issue.It works nice so far.
5e7d6bb
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.
with the new
direct
directive onroutes.rb
this feature definitely should be back. for now I will be using the GitLab solution described by @tomaadland.5e7d6bb
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.
@tomaadland I know some time went by, but right now I have this issue up again. Is your mentioned solution from gitlab not very imperformant? Loading the route files every request looks not very optimal for me.
Right now I couldn't find any solution to make it work with routing concerns, so I really miss the built-in feature to split up routes.
5e7d6bb
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.
This feature exists on Rails master already #37892