Rob
2006-Dec-03 22:04 UTC
Confused on how to set up multiple ''category'' controllers using REST/Resources.
I have two controllers - say "food" and "images" (not related to each other at all). Each one will have different categories; I''d like to access them via /categories/2/food, /categories/2/images, etc. But obviously that won''t work, will it? How would I go about setting it up? The only way I could think of would be giving a different name for each category.. i.e: /cat_food/2/food, /cat_images/2/images.. but that looks very ugly. Is there an easier solution? --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
ljredpath-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org
2006-Dec-03 23:07 UTC
Re: Confused on how to set up multiple ''category'' controllers using REST/Resources.
Wouldn''t it make sense to have: /food/categories /images/categories ? --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
Pat Maddox
2006-Dec-03 23:19 UTC
Re: Confused on how to set up multiple ''category'' controllers using REST/Resources.
On 12/3/06, Rob <robaree-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> > I have two controllers - say "food" and "images" (not related to each > other at all). Each one will have different categories; I''d like to > access them via /categories/2/food, /categories/2/images, etc. > > But obviously that won''t work, will it?Nested resources ActionController::Routing::Routes.draw do |map| map.resources :categories do |category| map.resources :foods, :images end end --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
Pat Maddox
2006-Dec-03 23:20 UTC
Re: Confused on how to set up multiple ''category'' controllers using REST/Resources.
On 12/3/06, Pat Maddox <pergesu-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> On 12/3/06, Rob <robaree-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > > > I have two controllers - say "food" and "images" (not related to each > > other at all). Each one will have different categories; I''d like to > > access them via /categories/2/food, /categories/2/images, etc. > > > > But obviously that won''t work, will it? > > Nested resources > > ActionController::Routing::Routes.draw do |map| > map.resources :categories do |category| > map.resources :foods, :images > end > end >that should be category.resources :foods, :images --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
Rob
2006-Dec-04 18:17 UTC
Re: Confused on how to set up multiple ''category'' controllers using REST/Resources.
How would I use a single category model/table if I need different categories for ''images'' and ''food''? On 12/3/06, Pat Maddox <pergesu-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> > On 12/3/06, Pat Maddox <pergesu-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > On 12/3/06, Rob <robaree-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > > > > > I have two controllers - say "food" and "images" (not related to each > > > other at all). Each one will have different categories; I''d like to > > > access them via /categories/2/food, /categories/2/images, etc. > > > > > > But obviously that won''t work, will it? > > > > Nested resources > > > > ActionController::Routing::Routes.draw do |map| > > map.resources :categories do |category| > > map.resources :foods, :images > > end > > end > > > > that should be > category.resources :foods, :images > > > >--~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
ljredpath-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org
2006-Dec-05 23:08 UTC
Re: Confused on how to set up multiple ''category'' controllers using REST/Resources.
Polymorphic associations. http://wiki.rubyonrails.org/rails/pages/UnderstandingPolymorphicAssociations --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---