# Named Routes parameter errors

**URL:** <https://www.ruby-forum.com/t/named-routes-parameter-errors/115453>\
**Category:** Rails\
**Created:** [September 25, 2007, 2:05pm UTC](https://www.ruby-forum.com/t/named-routes-parameter-errors/115453 "2007-09-25T14:05:19Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![bitsmith](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/b/9de053/32.png) [@bitsmith](https://www.ruby-forum.com/u/bitsmith)\
**Post date:** [September 25, 2007, 2:05pm UTC](https://www.ruby-forum.com/t/named-routes-parameter-errors/115453/1 "2007-09-25T14:05:19Z")

</div>

Hello all. I have many questions regarding routes:

First of all, I had a route that looked like this:  
map.connect ‘/person/:id/  
tag/:tag\_id’, :controller=\>:person, :action=\>:tag

I was trying to link to this URL with this code:  
link\_to tag.name, :action=\>:tag, :id=\>@person.id, :tag\_id=\>tag.id

Instead of generating the URL I desired ( /person/1/tag/2 ), the URL  
generated slipped through to my default route: /person/tag/1?tag\_id=2

Question #1: Why does Rails generate the URL based on a route which is  
lower in my priority list in routes.rb

When I asked this question in #rubyonrails the response I got was to  
just use a named route instead. I’m not opposed to this idea but I  
would still like a real answer to Question 1.

I made a named route:  
map.with\_options :controller=\>:person do |c|  
c.person\_tag ‘person/:id/tag/:tag\_id’, :action=\>:tag  
end

This doesn’t even “compile” unless you change :person to a string

Question #2: Why must controllers not be symbols in a named route

Linking to this named route like so: link\_to tag.name,  
person\_tag\_url(:id=\>@person.id, :tag\_id=\>tag.id)  
produces an error:  
person\_tag\_url failed to generate from  
{:controller=\>“person”, :action=\>“tag”, :tag\_id=\>“13”, :id=\>“1”},  
expected: {:controller=\>“person”, :action=\>:tag}, diff:  
{:action=\>:tag, :tag\_id=\>“13”, :id=\>“1”}

For some reason it doesn’t expect my :id and :tag\_id, so I’ll try to  
give it what it wants. I change the link to:  
link\_to tag.name, person\_tag\_url()  
And get this error:  
person\_tag\_url failed to generate from  
{:controller=\>“person”, :action=\>“tag”}, expected:  
{:controller=\>“person”, :action=\>:tag}, diff: {:action=\>:tag}

Looks like it wants tag to be a symbol. Well, since I didn’t  
explicitly give tag as a string, I’ll change what it expects in my  
route to look like this:  
map.with\_options :controller=\>‘person’ do |c|  
c.person\_tag ‘person/:id/tag/:tag\_id’, :action=\>‘tag’  
end  
However, now I get the error message:  
person\_tag\_url failed to generate from  
{:controller=\>“person”, :action=\>“tag”} - you may have ambiguous  
routes, or you may need to supply additional parameters for this  
route. content\_url has the following required parameters:  
[“person”, :id, “tag”, :tag\_id] - are they all satisifed?

So it looks like I’m passing the parameters it’s “expecting” now, but  
the error message I get now is that additional parameters are  
required. Supplying those parameters generates the other “failed to  
generate” error described above.

Question #3: Can anybody point out what I am doing incorrectly?

Thanks!
