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 --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
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 --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---