-
Notifications
You must be signed in to change notification settings - Fork 509
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
Routes not doing what I would like them to do. #618
Comments
For the first question |
I understand that index may be reserved, but is reindex? |
You are right, but we need to parse better to replace |
Cool. Which part of the framework deals with this? I might take a look at it myself also |
@philly-mac Yeah I totally agree this needs to be fixed and perhaps rethought about. Here is the exact method/lines: https://github.com/padrino/padrino-framework/blob/master/padrino-core/lib/padrino-core/application/routing.rb#L588. Right now we are doing a regex that is clearly not working. We should add a failing test for an action called reindex. I can see the case for "stripping" out any of the reserved actions from the path as you suggest. "destroy" action becomes: DELETE /resource/id, etc to stick with restful conventions. Perhaps the key is to support this with a separate plugin, I am not entirely sure. Perhaps we can brainstorm a "better" way for routing to work which can be enabled that makes all destroy,update,show,create,index all reserved words? @DAddYE what do you think about this idea. |
@nesquena A plugin would be a good solution I think, something that you could just require to get the restful type routes. I went back to actually look at the way sinatra was doing its routes, and I like them because they are simple and consistent, and sometimes I would just like to be able to use routes as defined by sinatra. So I think a plugin should add that when any of the 7 methods are used in their proper context then they become the restful route. delete :destroy do... #=> DELETE /resource/:id I think it only makes sense to reserve the rest methods for the http methods that they apply to, and not just globally. Also the rails guides has a perfect table of all methods and what they should map to http://guides.rubyonrails.org/routing.html What do you think? |
You can use sinatra routing directly as well passing a string directly. The symbol notation is an optional addition. So you can still do: get "/foo/bar" do
end in Padrino. I do think a plugin or a flag to support the restful paths by default by stripping the various keywords when used in the right context is not a bad idea at all. I can see using it in various places throughout APIs. |
Ahhh okay, but with the string notation you do not get any routes displayed with the |
Also I don't know if you actually mention in the docs anywhere that the symbol notation is Padrino and string notation will give you sinatra routes, but you should make that clear somewhere as it is actually very useful to know. |
Strike my last comment, I just looked through the guides again, and it does mention the distinction of the symbols |
Added a failing test above, i.e reindex action |
Yeah, I'm working on this. |
Fixed in 790f349 |
Hi,
I have a route like this in one of my controllers
get :reindex do
When I do a padrino rake routes I see
(:tracks, :reindex) GET /tracks/re
Why is the router just chopping off the word index in any context?
furthermore could you actually explain why index seems to be the only one of the methods that has a special meaning in the context of the router?
Why doesn't
delete :destroy do ...
automatically map to something like
(:tracks, :destroy) DELETE /tracks/:id
The whole thing just seems very inconsistent to me, and I have always wondered why it worked this way.
Thanks
The text was updated successfully, but these errors were encountered: