In my rails app i have such route for carts controller:
resources :carts
so in layout, according to my logic i have:
= link_to "Моя корзина", @cart
and in browser i see for example:
******:3000/carts/112
Could i however do nested rails route show as post-like request? so i will have:
******:3000/carts/
also rake routes:
arts GET /carts(.:format) carts#index
POST /carts(.:format) carts#create
new_cart GET /carts/new(.:format) carts#new
edit_cart GET /carts/:id/edit(.:format) carts#edit
cart GET /carts/:id(.:format) carts#show
PUT /carts/:id(.:format) carts#update
DELETE /carts/:id(.:format) carts#destroy
cart POST /carts/:id(.:format) carts#show
I now how to write it for my own methods… But how to be with build-in show?
i need to change show route, so that id for show is sending not as get-param by url, but as post-param in request…
The
resourcesmethod simply puts in a bunch of predefined routes, as described here.Specifically, it is adding the equivalent of
If you want to use a different set of routes, don’t use
resources, and just define your own routes instead.Also, you can’t hide the cart id from the user this way. If the request contains the ID, it means that the user can see it. He might have to view it with Firebug or by looking at the page source instead of his address bar, but it’s still not secret or protected in any way.