Hi guys,just wondering if someone could enlighten me about this. Is it possible to have multi nested resources like map.resources :owners do |owner| owner.resources :dogs, :controller => ''dogs'', :singular => ''dog'', :name_prefix => ''owner_'' owner.resources :cats, :controller => ''cats'', :singular => ''cat'', :name_prefix => ''owner_'' end Just having a bit of trouble with routes... thanks! --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
You may be having trouble generating routes like I did when I first stated playing with it. :) To generate a route to, say, a dog, you''ll to provide something like this: owner_dog_path(@owner_id, @dog_id) Then Rails builds the URL off of the two id''s to produce something like http://yourapp.com/owners/1/dogs/2 or what have you. I suggest read the PDF mentioned here: http://www.rubyinside.com/restful-rails-development-pdf-released-392.html ...and referring to this cheatsheet: http://topfunky.com/clients/peepcode/REST-cheatsheet.pdf ...whenever you need it. --Jeremy On 8/20/07, Marc <marc.maleko-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> > Hi guys,just wondering if someone could enlighten me about this. > > Is it possible to have multi nested resources like > > map.resources :owners do |owner| > owner.resources :dogs, > :controller => ''dogs'', > :singular => ''dog'', > :name_prefix => ''owner_'' > owner.resources :cats, > :controller => ''cats'', > :singular => ''cat'', > :name_prefix => ''owner_'' > end > > Just having a bit of trouble with routes... thanks! > > > > >-- http://www.jeremymcanally.com/ My free Ruby e-book: http://www.humblelittlerubybook.com/book/ My blogs: http://www.mrneighborly.com/ http://www.rubyinpractice.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?hl=en -~----------~----~----~----~------~----~------~--~---
Jeremy is right -- you can next as deeply as you like. However, the deeper you go the more difficult it becomes to create the routes. I''ve got one spot in a project that is nested two levels deep and the code gets a bit annoying. AndyV On Aug 20, 9:47 am, "Jeremy McAnally" <jeremymcana...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> You may be having trouble generating routes like I did when I first > stated playing with it. :) > > To generate a route to, say, a dog, you''ll to provide something like this: > > owner_dog_path(@owner_id, @dog_id) > > Then Rails builds the URL off of the two id''s to produce something > likehttp://yourapp.com/owners/1/dogs/2or what have you. > > I suggest read the PDF mentioned here: > > http://www.rubyinside.com/restful-rails-development-pdf-released-392.... > > ...and referring to this cheatsheet: > > http://topfunky.com/clients/peepcode/REST-cheatsheet.pdf > > ...whenever you need it. > > --Jeremy > > On 8/20/07, Marc <marc.mal...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > > > > > > Hi guys,just wondering if someone could enlighten me about this. > > > Is it possible to have multi nested resources like > > > map.resources :owners do |owner| > > owner.resources :dogs, > > :controller => ''dogs'', > > :singular => ''dog'', > > :name_prefix => ''owner_'' > > owner.resources :cats, > > :controller => ''cats'', > > :singular => ''cat'', > > :name_prefix => ''owner_'' > > end > > > Just having a bit of trouble with routes... thanks! > > --http://www.jeremymcanally.com/ > > My free Ruby e-book:http://www.humblelittlerubybook.com/book/ > > My blogs:http://www.mrneighborly.com/http://www.rubyinpractice.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?hl=en -~----------~----~----~----~------~----~------~--~---
I had nested about five levels deep on a project before we realized it was stupid and we de-nested. The route generation looked something like this: site_section_unit_text_activity_file_path(params[:site_id], params[:section_id], params[:unit_id], params[:text_id], params[:activity_id], params[:id]) Ridiculous. :) --Jeremy On 8/20/07, AndyV <arv7-HmMyXyqgL2CVc3sceRu5cw@public.gmane.org> wrote:> > Jeremy is right -- you can next as deeply as you like. However, the > deeper you go the more difficult it becomes to create the routes. > I''ve got one spot in a project that is nested two levels deep and the > code gets a bit annoying. > > AndyV > > On Aug 20, 9:47 am, "Jeremy McAnally" <jeremymcana...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> > wrote: > > You may be having trouble generating routes like I did when I first > > stated playing with it. :) > > > > To generate a route to, say, a dog, you''ll to provide something like this: > > > > owner_dog_path(@owner_id, @dog_id) > > > > Then Rails builds the URL off of the two id''s to produce something > > likehttp://yourapp.com/owners/1/dogs/2or what have you. > > > > I suggest read the PDF mentioned here: > > > > http://www.rubyinside.com/restful-rails-development-pdf-released-392.... > > > > ...and referring to this cheatsheet: > > > > http://topfunky.com/clients/peepcode/REST-cheatsheet.pdf > > > > ...whenever you need it. > > > > --Jeremy > > > > On 8/20/07, Marc <marc.mal...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > > > > > > > > > > > > Hi guys,just wondering if someone could enlighten me about this. > > > > > Is it possible to have multi nested resources like > > > > > map.resources :owners do |owner| > > > owner.resources :dogs, > > > :controller => ''dogs'', > > > :singular => ''dog'', > > > :name_prefix => ''owner_'' > > > owner.resources :cats, > > > :controller => ''cats'', > > > :singular => ''cat'', > > > :name_prefix => ''owner_'' > > > end > > > > > Just having a bit of trouble with routes... thanks! > > > > --http://www.jeremymcanally.com/ > > > > My free Ruby e-book:http://www.humblelittlerubybook.com/book/ > > > > My blogs:http://www.mrneighborly.com/http://www.rubyinpractice.com/ > > > > >-- http://www.jeremymcanally.com/ My free Ruby e-book: http://www.humblelittlerubybook.com/book/ My blogs: http://www.mrneighborly.com/ http://www.rubyinpractice.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?hl=en -~----------~----~----~----~------~----~------~--~---
Hmm but I''m not trying to nest too deeply. It''s more like having two equal nests? An Owner can have a dog as well as a cat (let''s not get into like polymorphism for this case first =). How do you denote that on the routes? url path would be like: owner/1/dog/1 and owner/1/cat/1 On Aug 20, 11:47 pm, "Jeremy McAnally" <jeremymcana...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> You may be having trouble generating routes like I did when I first > stated playing with it. :) > > To generate a route to, say, a dog, you''ll to provide something like this: > > owner_dog_path(@owner_id, @dog_id) > > Then Rails builds the URL off of the two id''s to produce something > likehttp://yourapp.com/owners/1/dogs/2or what have you. > > I suggest read the PDF mentioned here: > > http://www.rubyinside.com/restful-rails-development-pdf-released-392.... > > ...and referring to this cheatsheet: > > http://topfunky.com/clients/peepcode/REST-cheatsheet.pdf > > ...whenever you need it. > > --Jeremy > > On 8/20/07, Marc <marc.mal...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > > > > > > Hi guys,just wondering if someone could enlighten me about this. > > > Is it possible to have multi nested resources like > > > map.resources :owners do |owner| > > owner.resources :dogs, > > :controller => ''dogs'', > > :singular => ''dog'', > > :name_prefix => ''owner_'' > > owner.resources :cats, > > :controller => ''cats'', > > :singular => ''cat'', > > :name_prefix => ''owner_'' > > end > > > Just having a bit of trouble with routes... thanks! > > --http://www.jeremymcanally.com/ > > My free Ruby e-book:http://www.humblelittlerubybook.com/book/ > > My blogs:http://www.mrneighborly.com/http://www.rubyinpractice.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?hl=en -~----------~----~----~----~------~----~------~--~---
argh ignore what I have posted, I found out the error of my ways... I forgot to put the prefix when i specified like: cat_path should have been owner_cat_path. doh. Thanks all =) --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---