# Routes Parameter manipulation

**URL:** <https://www.ruby-forum.com/t/routes-parameter-manipulation/161839>\
**Category:** Rails\
**Created:** [March 3, 2009, 12:00am UTC](https://www.ruby-forum.com/t/routes-parameter-manipulation/161839 "2009-03-03T00:00:23Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![Yanir](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/y/7ab992/32.png) [@Yanir](https://www.ruby-forum.com/u/Yanir)\
**Post date:** [March 3, 2009, 12:00am UTC](https://www.ruby-forum.com/t/routes-parameter-manipulation/161839/1 "2009-03-03T00:00:23Z")

</div>

I am creating a new site to replace an existing one and want to  
preserve urls that people have bookmarked and appear in search  
engines. My solution to this is create a route that takes a historical  
url and pass that along to the controller of my choice with a new id  
that was looked up in a table. This seems to work in theory but I am  
stuck on something.

Here is my approach:

I want to take the url: /category/123  
lookup 123 in a table which will return a new id for my new catalog.  
and send the user to a different controller with id 456 (or whatever  
the looked up value is)

I have a method that is called in the route and will return a value.  
The problem is passing the supplied id (named :cid in my code below).  
I can’t seem to pass the value that is in the url. Everything else  
works. I can hard code the parameter to the catmap method and the  
route works.

Routes.rb

def catmap(cat)

```
list ={'60'=>'2','61'=>'3'}

return list(cat)

```

end

class ApplicationController \< ActionController::Base  
…  
map.connect ‘category/:cid’,:controller =\> ‘list’, :action =\>  
‘model’, :id =\>catmap(cid)  
…  
end
