-
Notifications
You must be signed in to change notification settings - Fork 196
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
Order of routes affects pretty URLs #43
Comments
I think this is by design. Rails does basically the same. |
I don't think so, I understand that by design, the order of the routes is taken into account in the sense that the first match will be used (like Rails), but this is not the case here. |
@jaimeiniesta So this API might need a little more thought to make it intuitive. At the moment its by design, but your right, its not the most intuitive. Right now it matches top to bottom when going from params to a url. (and vice versa) get '/' matches anything, so it should be at the bottom. |
I'll leave this one open if anyone wants to discuss their thoughts on the routes. One of my goals with Volt is to have a simple routing system. Not needing to handle different http verbs allows us to simplify things. (Expect extra methods for building REST API's for the backend) I think the idea of routes just mapping params to urls and vice versa could make it easy to learn, but powerful enough to use day to day. |
Thanks for the explanation, in my opinion the best place for the root path is at the bottom, but I was surprised by this behavior. Volt does not need to behave like Rails, but in Rails, you can have the root route on the top of the routes file and everything will still work as if it was at the bottom. What I don't get is, why is it that I must surely be missing something about how routes are matched in Volt, but I can't find it in the docs. |
So front-end routing is a different thing than backend routing because you need to go from both url to params and params to url. So you can think of everything after the url string as constraints for matching.
Something like ```get '/about', {_controller: 'about'}, only matches when the params._controller == 'about'
Let me know if that makes since. Its simple, but maybe not intuitive enough. At this point all of these api's are open to change :-) |
Ah, alright, thanks a lot for your explanation!
That was the point that I was missing :) |
Cool, thats a good idea. I'll add that. On Sun, Sep 21, 2014 at 4:39 PM, Jaime Iniesta notifications@github.com
|
I added some more stuff to the readme and generated routes.rb files. Hopefully that helps newcomers. |
I've noticed that if you move the main "/" route to the top of the routes file, for example on https://github.com/voltrb/todos3/blob/master/app/main/config/routes.rb leaving it like this,
it affects the URLs so, although the app still works, you get ugly URLs like:
instead of
The text was updated successfully, but these errors were encountered: