Ball, Donald A Jr (Library)
2007-Aug-03 18:34 UTC
routing to arbitrary deeply nested resources
I''ve got a tree of nodes to which I want to route requests. Currently I''m using simple resource routing: map.resources :nodes Rather than a flat URLspace where all nodes are access via: /nodes/id I''d prefer an arbitrary deeply nested URLspace: /nodes/id /nodes/id/child /nodes/id/child/grandchild Both to make inserting new nodes simpler, and to make context-specific searching easier. Can anyone suggest how I might approach this problem? - donald --~--~---------~--~----~------------~-------~--~----~ 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@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Ball, Donald A Jr (Library) wrote:> I''ve got a tree of nodes to which I want to route requests. Currently > I''m using simple resource routing: > > map.resources :nodes > > Rather than a flat URLspace where all nodes are access via: > > /nodes/id > > I''d prefer an arbitrary deeply nested URLspace: > > /nodes/id > /nodes/id/child > /nodes/id/child/grandchild > > Both to make inserting new nodes simpler, and to make context-specific > searching easier. > > Can anyone suggest how I might approach this problem? > > - donaldUse * and write your own routing method? E.g.: map.connect ''nodes/*rparams'', :controller => "nodes", :action => "router" and rparams will be passed into router as an array of values. -- Michael Wang --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
Ball, Donald A Jr (Library)
2007-Aug-06 14:58 UTC
Re: routing to arbitrary deeply nested resources
> > I''ve got a tree of nodes to which I want to route requests. > Currently > > I''m using simple resource routing: > > > > map.resources :nodes > > > > Rather than a flat URLspace where all nodes are access via: > > > > /nodes/id > > > > I''d prefer an arbitrary deeply nested URLspace: > > > > /nodes/id > > /nodes/id/child > > /nodes/id/child/grandchild > > > > Both to make inserting new nodes simpler, and to make > context-specific > > searching easier. > > > > Can anyone suggest how I might approach this problem? > > > > - donald > > Use * and write your own routing method? E.g.: > > map.connect ''nodes/*rparams'', > :controller => "nodes", > :action => "router" > > and rparams will be passed into router as an array of values.That''s a thought, thanks for the suggestion. Sadly, it means I can''t use any of the nice url generator methods provided by rails routing, but it''d work. I''ll give it a whirl. - donald --~--~---------~--~----~------------~-------~--~----~ 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@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---