hi, lets say routes.rb has map.resources :foo and I want the show action to have a diffent url, so I add (after the above line) map.foo ''/bar/:id'', :controller => ''foo'', :action => ''show'' this works fine, including foo_path( :id => "1") => /bar/1 and <%= link_to ''Show'', foo %> But now this also seems to go to the show action, not destroy <%= link_to ''Destroy'', foo, :confirm => ''Are you sure?'', :method => :delete %> --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
jacob.dunphy-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org
2007-Nov-28 23:11 UTC
Re: overriding rest show route but not delete
Your named route map.foo goes explicitly to the show action. It''s overriding the path method created by the map.resources. On Nov 28, 2:46 pm, linojon <lino...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> hi, lets say routes.rb has > > map.resources :foo > > and I want the show action to have a diffent url, so I add (after the > above line) > > map.foo ''/bar/:id'', :controller => ''foo'', :action => ''show'' > > this works fine, including foo_path( :id => "1") => /bar/1 > and <%= link_to ''Show'', foo %> > > But now this also seems to go to the show action, not destroy > > <%= link_to ''Destroy'', foo, :confirm => ''Are you sure?'', :method > => :delete %>--~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
ok, so how can i make it override the show action but not the delete one, which has a similar path with different request method? On Nov 28, 6:11 pm, "jacob.dun...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org" <jacob.dun...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> Your named route map.foo goes explicitly to the show action. It''s > overriding the path method created by the map.resources. > > On Nov 28, 2:46 pm, linojon <lino...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > > hi, lets say routes.rb has > > > map.resources :foo > > > and I want the show action to have a diffent url, so I add (after the > > above line) > > > map.foo ''/bar/:id'', :controller => ''foo'', :action => ''show'' > > > this works fine, including foo_path( :id => "1") => /bar/1 > > and <%= link_to ''Show'', foo %> > > > But now this also seems to go to the show action, not destroy > > > <%= link_to ''Destroy'', foo, :confirm => ''Are you sure?'', :method > > => :delete %>--~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
jacob.dunphy-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org
2007-Nov-29 08:51 UTC
Re: overriding rest show route but not delete
If your example is an accurate representation of your application''s behavior, then you''re overriding the restful route method foo_url with the named map.foo, which will also generate a foo_url method. Give map.foo a different name, and the methods won''t conflict any more. On Nov 28, 11:40 pm, linoj <lino...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> ok, so how can i make it override the show action but not the delete > one, which has a similar path with different request method? > > On Nov 28, 6:11 pm, "jacob.dun...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org" <jacob.dun...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> > wrote: > > > Your named route map.foo goes explicitly to the show action. It''s > > overriding the path method created by the map.resources. > > > On Nov 28, 2:46 pm, linojon <lino...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > > > hi, lets say routes.rb has > > > > map.resources :foo > > > > and I want the show action to have a diffent url, so I add (after the > > > above line) > > > > map.foo ''/bar/:id'', :controller => ''foo'', :action => ''show'' > > > > this works fine, including foo_path( :id => "1") => /bar/1 > > > and <%= link_to ''Show'', foo %> > > > > But now this also seems to go to the show action, not destroy > > > > <%= link_to ''Destroy'', foo, :confirm => ''Are you sure?'', :method > > > => :delete %>--~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---