Pete Yandell
2006-Oct-18 01:04 UTC
Restful routes in edge and multiple paths to a resource
We''re rolling our own blog (http://blog.aliencamel.com/ if you want an explanation as to why on earth we''d do this), and I''m using a couple of nice restful routes in the obvious way: map.resources :articles do |articles| articles.resources :comments end Makes sense, but I''d also like to be able to have an independent route: map.resources :comments so that I can have an admin view of all the recent comments. This obviously doesn''t work because all the named routes clash, and I imagine I need a separate controller to handle it too, given the logic is a bit different. Is there a way to make this work which is neat and relatively painless, or should I just build a non-restful controller to handle it? Cheers, Pete Yandell http://aliencamel.com/ P.S. I tried posting this message to the list via email a couple of days ago, but it hasn''t appeared. My apologies if it suddenly shows up and becomes a duplicate. --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
Rick Olson
2006-Oct-18 14:14 UTC
Re: Restful routes in edge and multiple paths to a resource
On 10/17/06, Pete Yandell <pete.yandell-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> > We''re rolling our own blog (http://blog.aliencamel.com/ if you want an > explanation as to why on earth we''d do this), and I''m using a couple of > nice restful routes in the obvious way: > > map.resources :articles do |articles| > articles.resources :comments > end > > Makes sense, but I''d also like to be able to have an independent route: > > map.resources :comments > > so that I can have an admin view of all the recent comments. This > obviously doesn''t work because all the named routes clash, and I > imagine I need a separate controller to handle it too, given the logic > is a bit different. > > Is there a way to make this work which is neat and relatively painless, > or should I just build a non-restful controller to handle it?You can define the duplicate comment routes with the :name_prefix option. -- Rick Olson http://weblog.techno-weenie.net http://mephistoblog.com --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---