# Named\_route\_url broken in 1.2?

**URL:** <https://www.ruby-forum.com/t/named-route-url-broken-in-1-2/103581>\
**Category:** Rails\
**Created:** [May 8, 2007, 3:55am UTC](https://www.ruby-forum.com/t/named-route-url-broken-in-1-2/103581 "2007-05-08T03:55:15Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![joe](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/b9e5f3/32.png) [@joe](https://www.ruby-forum.com/u/joe)\
**Post date:** [May 8, 2007, 3:55am UTC](https://www.ruby-forum.com/t/named-route-url-broken-in-1-2/103581/1 "2007-05-08T03:55:15Z")

</div>

Wow, I sure have wasted a lot of time trying to get my named routes to  
work in Rails 1.2. Everything worked fine in 1.1. I’m ready to kill  
whoever rewrote the routing and broke BC. My routes:

#map.item ‘item/:id’, :controller=\>‘items’, :action=\>‘show’,  
:order=\>nil, :requirements =\> {:id =\> /\d+/}  
map.item ‘item/type/:type/category/:category\_id’,  
:controller=\>‘items’, :action=\>‘show’, :category\_id =\> /\d+/, :id =\>  
/\d+/  
map.item ‘item/type/:type/:id’, :controller=\>‘items’, :action=\>‘show’,  
:type=\>/\w+/, :id =\> /\d+/  
map.item ‘item/category/:category\_id’, :controller=\>‘items’,  
:action=\>‘show’, :category\_id =\> /\d+/, :id =\> /\d+/  
map.item ‘item/:id’, :controller=\>‘items’, :action=\>‘show’, :id =\>  
/\d+/  
#map.item ‘item/:id/:order’, :controller=\>‘items’, :action=\>‘show’,  
:requirements =\> {:id =\> /\d+/}

I either get an error like this:

`raise\_named\_route\_error’: item\_url failed to generate from  
{:order=\>“added”, :id=\>“88725”, :action=\>“show”, :type=\>“pictures”,  
:controller=\>“items”}, expected: {:action=\>“show”, :type=\>nil,  
:controller=\>“items”}, diff: {:order=\>“added”, :id=\>“88725”, :type=\>nil}

or generated URLs look like this:

/item/12345?order=views&type=foo

when they should look like this:

/item/type/foo/12345

WTF?

Joe R. MUDCRAP-CE

---

<div class="post-metadata">

**Author:** ![joe](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/b9e5f3/32.png) [@joe](https://www.ruby-forum.com/u/joe)\
**Post date:** [May 8, 2007, 8:07am UTC](https://www.ruby-forum.com/t/named-route-url-broken-in-1-2/103581/2 "2007-05-08T08:07:48Z")

</div>

> Wow, I sure have wasted a lot of time trying to get my named routes to  
> work in Rails 1.2. Everything worked fine in 1.1. I’m ready to kill  
> whoever rewrote the routing and broke BC. My routes:

The first rule of free, technical support is that you’re asking for  
it, not entitled to it. Thus, you get further by asking nicely. You’re  
not asking very nicely, so you shouldn’t be surprised if you’re not  
getting a lot of help.

> map.item ‘item/type/:type/category/:category\_id’,  
> :controller=\>‘items’, :action=\>‘show’, :category\_id =\> /\d+/, :id =\>  
> /\d+/  
> map.item ‘item/type/:type/:id’, :controller=\>‘items’, :action=\>‘show’,

You’re declaring multiple named routes with the same name. These will  
overwrite each other. There can only be one item\_url method. Come up  
with different names, like map.type\_category\_item, map.type\_item, etc.

> WTF?

Attitude is an expensive luxury and you’ve already maxed out all your  
good-will credit cards.

---

<div class="post-metadata">

**Author:** ![joe](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/b9e5f3/32.png) [@joe](https://www.ruby-forum.com/u/joe)\
**Post date:** [May 8, 2007, 8:17am UTC](https://www.ruby-forum.com/t/named-route-url-broken-in-1-2/103581/3 "2007-05-08T08:17:46Z")

</div>

DHH wrote:

> > Wow, I sure have wasted a lot of time trying to get my named routes to  
> > work in Rails 1.2. Everything worked fine in 1.1. I’m ready to kill  
> > whoever rewrote the routing and broke BC. My routes:
> 
> The first rule of free, technical support is that you’re asking for  
> it, not entitled to it. Thus, you get further by asking nicely. You’re  
> not asking very nicely, so you shouldn’t be surprised if you’re not  
> getting a lot of help.
> 
> > map.item ‘item/type/:type/category/:category\_id’,  
> > :controller=\>‘items’, :action=\>‘show’, :category\_id =\> /\d+/, :id =\>  
> > /\d+/  
> > map.item ‘item/type/:type/:id’, :controller=\>‘items’, :action=\>‘show’,
> 
> You’re declaring multiple named routes with the same name. These will  
> overwrite each other. There can only be one item\_url method. Come up  
> with different names, like map.type\_category\_item, map.type\_item, etc.

Wow, really?!? I can’t remember who/what told me it was possible to use  
multiple named routes of the same name (perhaps Jarkko I think). Well,  
that sucks it’s not possible! Anyhow, thanks for clueing me in!

> > WTF?
> 
> Attitude is an expensive luxury and you’ve already maxed out all your  
> good-will credit cards.

Hey, I’m MUDCRAP certified! Suck it! 😜

Joe R. MUDCRAP-CE

---

<div class="post-metadata">

**Author:** ![joe](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/b9e5f3/32.png) [@joe](https://www.ruby-forum.com/u/joe)\
**Post date:** [May 8, 2007, 8:25am UTC](https://www.ruby-forum.com/t/named-route-url-broken-in-1-2/103581/4 "2007-05-08T08:25:32Z")

</div>

DHH wrote:

> > map.item ‘item/type/:type/category/:category\_id’,  
> > :controller=\>‘items’, :action=\>‘show’, :category\_id =\> /\d+/, :id =\>  
> > /\d+/  
> > map.item ‘item/type/:type/:id’, :controller=\>‘items’, :action=\>‘show’,
> 
> You’re declaring multiple named routes with the same name. These will  
> overwrite each other. There can only be one item\_url method. Come up  
> with different names, like map.type\_category\_item, map.type\_item, etc.

Seriously, DHH, thanks for pointing that out. You likely saved me  
additional hours of banging my head against the screen mistakenly  
believing that multiple named routes with the same name were possible  
(and why shouldn’t I since they worked before and the docs make no  
mention they’re not?). An error should probably result if there’s more  
than one named route with the same name.

I was just venting, with tongue in cheek. 😜 I’m used to the rougher  
treatment in Zed’s forum. 😜

Cheers,  
Joe R.
