Hi, I find it would be very convenient to nest resources in two levels, so a member is only sensible as a part of a club, and a fee pament is only sensible in the context of a club and a member. Is it possible to nest nested resources? How would the syntax be? I have tried just nesting the assignment in routes.rb, but failed to get it right What do ou think? Is it possible? /Fredrik -- "Give up learning, and put an end to your troubles." --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
map.resources :foos do |foo| foo.resources :bars do |bar| bar.resources :bazs end end -- Posted via http://www.ruby-forum.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 -~----------~----~----~----~------~----~------~--~---
Alternatively: map.resources :foos do |foo| foo.resources :bars, :has_many => :bazs end -- Posted via http://www.ruby-forum.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 -~----------~----~----~----~------~----~------~--~---
Hi Fredrik, Just a small warning from my own experience: nesting deeper than 1 level is not advised. It will become very tedious to keep supplying the unneeded lower levels of nesting in the url. If you know the "bar", you implicitly also know the "foo". So there is really no need to keep suppling the "foo", "bar" & "baz" all the time. I generally use the following nesting setup: map.resources :foos do |foo| foo.resources :bars end map.resources :bars do |bar| bar.resources :bazs end map.resources :bazs This way your routes to the "baz" don''t require a "foo". Also, if you know the "baz" resource, you can always create a direct route. For the index, new & create actions on "baz", you can the choose the route which also requires the "bar" to define the scope. Regards, Bas On Mar 7, 8:40 pm, Gerjan Stokkink <rails-mailing-l...-ARtvInVfO7ksV2N9l4h3zg@public.gmane.org> wrote:> Alternatively: > > map.resources :foos do |foo| > foo.resources :bars, :has_many => :bazs > end > -- > Posted viahttp://www.ruby-forum.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 -~----------~----~----~----~------~----~------~--~---
+1. It''s been widely discussed elsewhere and many of the insiders suggest not nesting more than 2 levels deep. On Mar 8, 5:49 am, Bas van Westing <basvanwest...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> Hi Fredrik, > > Just a small warning from my own experience: nesting deeper than 1 > level is not advised. > It will become very tedious to keep supplying the unneeded lower > levels of nesting in the url. If you know the "bar", you implicitly > also know the "foo". So there is really no need to keep suppling the > "foo", "bar" & "baz" all the time. > > I generally use the following nesting setup: > > map.resources :foos do |foo| > foo.resources :bars > end > > map.resources :bars do |bar| > bar.resources :bazs > end > > map.resources :bazs > > This way your routes to the "baz" don''t require a "foo". > Also, if you know the "baz" resource, you can always create a direct > route. For the index, new & create actions on "baz", you can the > choose the route which also requires the "bar" to define the scope. > > Regards, Bas > > On Mar 7, 8:40 pm, Gerjan Stokkink <rails-mailing-l...-ARtvInVfO7ksV2N9l4h3zg@public.gmane.org> > wrote: > > > Alternatively: > > > map.resources :foos do |foo| > > foo.resources :bars, :has_many => :bazs > > end > > -- > > Posted viahttp://www.ruby-forum.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 -~----------~----~----~----~------~----~------~--~---