Overriding restful routes

Hi!
i got those 2 routes:
map.preferences ‘/preferences’, :controller => ‘preferences’, :action
=> ‘new’, :requirements => { :method => :get }
map.resource :preferences

what i want to do is:

  • if user type address /preferences it goes to new, instead of index.
    (this point works)
  • if method is other than a “get” method, it should do the usual REST
    action (it doesn’t work).

someone know how i do it?

It sounds like you are hacking the singleton resource to fit your url
to show as /preferences. I have created a patch that might help you in
this case.

http://dev.rubyonrails.org/ticket/10578

But anyway still, with your hack the easiest thing to do would be to
use the resources and redirect to new on the GET index.

On Dec 21, 1:45 pm, “Jean-Sébastien” [email protected]

your patch looks nice.

And i have others question about your patch.
does it manage internationalization?
i mean /productos/1 and /products/1 would be the same page or just
spanish is available?

i just try your patch but doesn’t works for me… i don’t know why.
i’ll find the problem.

On Dec 21, 2:09 pm, “Jean-Sébastien” [email protected]

what error did you get?

On Dec 21, 6:41 pm, “Jean-Sébastien” [email protected]

I am afraid, it cannot handle internationalisation

On Dec 21, 6:09 pm, “Jean-Sébastien” [email protected]

ufff feel stupid, it works perfectly (i made a routing error)

Good to know that.

May be you should update the ticket with your experience, so others
might benefit. Thanks.

On Dec 22, 5:26 am, “Jean-Sébastien” [email protected]