DanielFischer.com
2007-Aug-09 21:25 UTC
Question about routing polymorphic associations, especially RAILS EDGE
I have a question regarding edge rails. The new routes syntax is: map.resources :blog, :has_many => :posts. Now my question is how would I further specify the association? I want :posts to ''has_many :comments''. But you can''t do: map.resources :blog, :has_many => :posts(:has_many => :comments) You can tell what I mean. I don''t think it makes sense to do map.resources :posts, :has_many => :comments because the whole point of nesting posts is so you can''t get it by itself. So how do I further nest it? I tried something like this: map.resources :shows do |shows| shows.resources :has_many => :episodes do |episode| episode.resources :has_many => :comments end end and did rake routes but I didn''t see anything like /shows/:id/ episodes/:id/comments/new Help would be greatly appreciated, 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 -~----------~----~----~----~------~----~------~--~---
linoj
2007-Aug-10 03:02 UTC
Re: Question about routing polymorphic associations, especially RAILS EDGE
Hi, afaik, if you want to use that syntax, rails edge endorses (enforces?) the notion that resources need not (should not) be nested more than one level deep in the url, because more is redundant. When you say /blog/12/posts/3/comments the blog_id is know from the @post record. Thus, /posts/3/comments is sufficient, and all that is supported. On Aug 9, 5:25 pm, "DanielFischer.com" <arac...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> I have a question regarding edge rails. The new routes syntax is: > > map.resources :blog, :has_many => :posts. > > Now my question is how would I further specify the association? I > want :posts to ''has_many :comments''. > > But you can''t do: > > map.resources :blog, :has_many => :posts(:has_many => :comments) > > You can tell what I mean. > > I don''t think it makes sense to do map.resources :posts, :has_many > => :comments because the whole point of nesting posts is so you can''t > get it by itself. So how do I further nest it? > > I tried something like this: > > map.resources :shows do |shows| > shows.resources :has_many => :episodes do |episode| > episode.resources :has_many => :comments > end > end > > and did rake routes but I didn''t see anything like /shows/:id/ > episodes/:id/comments/new > > Help would be greatly appreciated, 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 -~----------~----~----~----~------~----~------~--~---