# Route conflict - help resolving

**URL:** <https://www.ruby-forum.com/t/route-conflict-help-resolving/188763>\
**Category:** Rails\
**Created:** [May 18, 2010, 7:18am UTC](https://www.ruby-forum.com/t/route-conflict-help-resolving/188763 "2010-05-18T07:18:12Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![sso](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/f07891/32.png) [@sso](https://www.ruby-forum.com/u/sso)\
**Post date:** [May 18, 2010, 7:18am UTC](https://www.ruby-forum.com/t/route-conflict-help-resolving/188763/1 "2010-05-18T07:18:12Z")

</div>

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! 🙂

---

<div class="post-metadata">

**Author:** ![sso](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/f07891/32.png) [@sso](https://www.ruby-forum.com/u/sso)\
**Post date:** [May 18, 2010, 3:25pm UTC](https://www.ruby-forum.com/t/route-conflict-help-resolving/188763/2 "2010-05-18T15:25:17Z")

</div>

On Tue, May 18, 2010 at 1:16 AM, sso [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> 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/](http://talklikeaduck.denhaven2.com/)  
Github: [rubyredrick (Rick DeNatale) · GitHub](http://github.com/rubyredrick)  
Twitter: @RickDeNatale  
WWR: [http://www.workingwithrails.com/person/9021-rick-denatale](http://www.workingwithrails.com/person/9021-rick-denatale)  
LinkedIn: [http://www.linkedin.com/in/rickdenatale](http://www.linkedin.com/in/rickdenatale)

---

<div class="post-metadata">

**Author:** ![sso](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/f07891/32.png) [@sso](https://www.ruby-forum.com/u/sso)\
**Post date:** [May 18, 2010, 4:33pm UTC](https://www.ruby-forum.com/t/route-conflict-help-resolving/188763/3 "2010-05-18T16:33:47Z")

</div>

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 B. has an episode on this if you’re interested:

> **[\#139 Nested Resources - RailsCasts](http://railscasts.com/episodes/139-nested-resources)**
>
> Short Ruby on Rails screencasts containing tips, tricks and tutorials. Great for both novice and experienced web developers.

---

<div class="post-metadata">

**Author:** ![sso](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/f07891/32.png) [@sso](https://www.ruby-forum.com/u/sso)\
**Post date:** [May 18, 2010, 5:21pm UTC](https://www.ruby-forum.com/t/route-conflict-help-resolving/188763/4 "2010-05-18T17:21:48Z")

</div>

You may be right. I thought he was using RESTful routing, but had  
syntax errors in the manual mappings.

---

<div class="post-metadata">

**Author:** ![sso](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/f07891/32.png) [@sso](https://www.ruby-forum.com/u/sso)\
**Post date:** [May 18, 2010, 4:53pm UTC](https://www.ruby-forum.com/t/route-conflict-help-resolving/188763/5 "2010-05-18T16:53:42Z")

</div>

On Tue, May 18, 2010 at 10:32 AM, Sharagoz [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) 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\_id

Yes, 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/](http://talklikeaduck.denhaven2.com/)  
Github: [rubyredrick (Rick DeNatale) · GitHub](http://github.com/rubyredrick)  
Twitter: @RickDeNatale  
WWR: [http://www.workingwithrails.com/person/9021-rick-denatale](http://www.workingwithrails.com/person/9021-rick-denatale)  
LinkedIn: [http://www.linkedin.com/in/rickdenatale](http://www.linkedin.com/in/rickdenatale)
