tobyclemson-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org
2007-Aug-03 14:50 UTC
Nested Resources vs. Normal Resources
Hi, I''m a bit unsure as to when one uses a nested resource and when one uses a normal resource. If you have a belongs_to, has_one/many relationship between models is that automatically an indication of a nested resource or can these resources still be represented in the normal resource way? I have a resource (talker) that belongs_to a number of other models (network, data_date, talker_type etc) in a many to one relationship and I''d like to be able to have something like: /networks/1/talkers/10 /data_dates/1/talkers/10 /talker_types/1/talkers/10 but also /talkers/10 Is it possible to do this? or do I need to rename each of the nested parts of the url to something like network_talkers etc. so that it would be: /networks/1/network_talkers/10 ? Thanks, Toby --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
Don''t use nested resource unless you have a valid reason. http://groups.google.com/group/rubyonrails-core/browse_thread/thread/f4ca7b1d420f6d7d/63a18f62d6cc7364?q=Nested+Resource&lnk=ol& is a nice read. On 8/3/07, tobyclemson-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org <tobyclemson-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> > Hi, > > I''m a bit unsure as to when one uses a nested resource and when one > uses a normal resource. If you have a belongs_to, has_one/many > relationship between models is that automatically an indication of a > nested resource or can these resources still be represented in the > normal resource way? > > I have a resource (talker) that belongs_to a number of other models > (network, data_date, talker_type etc) in a many to one relationship > and I''d like to be able to have something like: > > /networks/1/talkers/10 > /data_dates/1/talkers/10 > /talker_types/1/talkers/10 > > but also > > /talkers/10 > > Is it possible to do this? or do I need to rename each of the nested > parts of the url to something like network_talkers etc. so that it > would be: > > /networks/1/network_talkers/10 > > ? > > Thanks, > Toby > > > > >-- Cheers! - Pratik http://m.onkey.org --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---