Forum: Ruby on Rails Routes Parameter manipulation

Announcement (2017-05-07): is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see and for other Rails- und Ruby-related community platforms.
Yanir (Guest)
on 2009-03-03 01:00
(Received via mailing list)
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.


  def catmap(cat)

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

    return list(cat)

class ApplicationController < ActionController::Base
  map.connect 'category/:cid',:controller => 'list', :action =>
'model', :id =>catmap(cid)
This topic is locked and can not be replied to.