# Problem generating url helper

**URL:** <https://www.ruby-forum.com/t/problem-generating-url-helper/184147>\
**Category:** Rails\
**Created:** [February 25, 2010, 6:29pm UTC](https://www.ruby-forum.com/t/problem-generating-url-helper/184147 "2010-02-25T18:29:08Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![aldoitalo](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/a587f6/32.png) [@aldoitalo](https://www.ruby-forum.com/u/aldoitalo)\
**Post date:** [February 25, 2010, 6:29pm UTC](https://www.ruby-forum.com/t/problem-generating-url-helper/184147/1 "2010-02-25T18:29:08Z")

</div>

i have a problem with generating a url with the helper.

in the routes.rb:

# cats

map.cat ‘/category/:id/:page’, :namespace =\> ‘front’, :controller =\>  
‘cats’, :action =\> ‘cat’, :requirements =\> { :page =\> /\d+/ }, :page =\>  
nil  
map.cat ‘/category/:id’, :namespace =\> ‘front’, :controller =\> ‘cats’,  
:action =\> ‘cat’

when the url is generating from will\_paginate plugin helper it work  
fine.  
but if i want to set my personal helper to build the url with the page,  
example:

\<%= cat\_url( @obj.id, var\_numb\_page ) =\>  
where “var\_numb\_page” is a integer indicates the :page param

i have this error:

undefined method `has\_key?’ for 2:Fixnum

i not understand where is the problem.

---

<div class="post-metadata">

**Author:** ![aldoitalo](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/a587f6/32.png) [@aldoitalo](https://www.ruby-forum.com/u/aldoitalo)\
**Post date:** [February 25, 2010, 9:10pm UTC](https://www.ruby-forum.com/t/problem-generating-url-helper/184147/2 "2010-02-25T21:10:02Z")

</div>

On Feb 25, 2010, at 9:29 AM, Aldo I. wrote:

> map.cat ‘/category/:id’, :namespace =\> ‘front’, :controller =\> ‘cats’,  
> :action =\> ‘cat’

Why do you have two routes named the same thing (“cat”)? Get rid of  
the second one since you’re allowing page to be nil in the first.

I think the error your getting is because cat\_url is trying to match  
against “/category/:id” which only has a single argument and you’re  
supplying two and it’s complaining about that.
