These are the routes I would like: map.forums_new_topic ''forums/:forum_id/:subsection_id/topics/ new'', :controller => "topics", :action => "new" map.forums_show_topic ''forums/:forum_id/:subsection_id/:topic_id'', :controller => "topics", :action => "show" however no matter which order they''re in it seems like it always tries to use the "show" route and it crashes because "topics" isn''t a id. Suggestions? Am I doing this the right way? 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
On Tue, May 18, 2010 at 1:16 AM, sso <strongsilentone-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> These are the routes I would like: > map.forums_new_topic ''forums/:forum_id/:subsection_id/topics/ > new'', :controller => "topics", :action => "new" > map.forums_show_topic > ''forums/:forum_id/:subsection_id/:topic_id'', :controller => > "topics", :action => "show" > > however no matter which order they''re in it seems like it always tries > to use the "show" route and it crashes because "topics" isn''t a id. > > Suggestions? Am I doing this the right way?Maybe if you restricted the format of the topic_id map.forums_show_topic ''forums/:forum_id/:subsection_id/:topic_id'', :topic_id => /\d+/, :controller => ''topics'', :action => ''show'' -- Rick DeNatale Blog: http://talklikeaduck.denhaven2.com/ Github: http://github.com/rubyredrick Twitter: @RickDeNatale WWR: http://www.workingwithrails.com/person/9021-rick-denatale LinkedIn: http://www.linkedin.com/in/rickdenatale -- 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@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.
Shallow routing was added to Rails 2.2, and encourage you to check it out. I never use deeply nested routes myself, because I don''t see the point in adding information, that you already have, to the URL. By setting :shallow => true on the resource mappings, this: GET forums/:forum_id/subsection/:subsection_id/topics/topic_id will turn into this: GET topics/topic_id Ryan Bates has an episode on this if you''re interested: http://railscasts.com/episodes/139-nested-resources On May 18, 3:24 pm, Rick DeNatale <rick.denat...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> On Tue, May 18, 2010 at 1:16 AM, sso <strongsilent...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > These are the routes I would like: > > map.forums_new_topic ''forums/:forum_id/:subsection_id/topics/ > > new'', :controller => "topics", :action => "new" > > map.forums_show_topic > > ''forums/:forum_id/:subsection_id/:topic_id'', :controller => > > "topics", :action => "show" > > > however no matter which order they''re in it seems like it always tries > > to use the "show" route and it crashes because "topics" isn''t a id. > > > Suggestions? Am I doing this the right way? > > Maybe if you restricted the format of the topic_id > > map.forums_show_topic ''forums/:forum_id/:subsection_id/:topic_id'', > :topic_id => /\d+/, :controller => ''topics'', :action => ''show'' > > -- > Rick DeNatale > > Blog:http://talklikeaduck.denhaven2.com/ > Github:http://github.com/rubyredrick > Twitter: @RickDeNatale > WWR:http://www.workingwithrails.com/person/9021-rick-denatale > LinkedIn:http://www.linkedin.com/in/rickdenatale > > -- > 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org > To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com. > For more options, visit this group athttp://groups.google.com/group/rubyonrails-talk?hl=en.-- 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@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.
On Tue, May 18, 2010 at 10:32 AM, Sharagoz <sharagoz-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> Shallow routing was added to Rails 2.2, and encourage you to check it > out. > I never use deeply nested routes myself, because I don''t see the point > in adding information, that you already have, to the URL. > > By setting :shallow => true on the resource mappings, this: > GET forums/:forum_id/subsection/:subsection_id/topics/topic_id > will turn into this: > GET topics/topic_idYes, but I took the OP at his word that he wanted particular routes/urls. He wasn''t using RESTful routing, something which I noticed but decided not to mention in trying to attack his question directly. -- Rick DeNatale Blog: http://talklikeaduck.denhaven2.com/ Github: http://github.com/rubyredrick Twitter: @RickDeNatale WWR: http://www.workingwithrails.com/person/9021-rick-denatale LinkedIn: http://www.linkedin.com/in/rickdenatale -- 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
You may be right. I thought he was using RESTful routing, but had syntax errors in the manual mappings. On May 18, 4:52 pm, Rick DeNatale <rick.denat...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> He wasn''t using RESTful routing, something which I noticed but decided > not to mention in trying to attack his question directly. > > -- > Rick DeNatale > > Blog:http://talklikeaduck.denhaven2.com/ > Github:http://github.com/rubyredrick > Twitter: @RickDeNatale > WWR:http://www.workingwithrails.com/person/9021-rick-denatale > LinkedIn:http://www.linkedin.com/in/rickdenatale > > -- > 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org > To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com. > For more options, visit this group athttp://groups.google.com/group/rubyonrails-talk?hl=en.-- 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@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.