You must have seen http://twitter.com/legalizenet where legalizenet is my screen name and I get a first context on twitter.com like every user. Its just one line of definition in the Rails routes.rb file. Just add following map.connect ‘:screen_name’, :controller => “<somecontroller>”, :action=> “<someaction>”(Note: replace <somecontroller> with right controller name and <someaction> with a right action in that controller)e.g it might look like map.connect ‘:screen_name’, :controller => “profile”, :action=> “home”This will tell rails engine , whenever there is a url like http://<hostname>/<screen_name> send request to profile_controller.rb’s “home” action. and then in home action method just do followingparams[:screen_name] and process it accordingly.Sweet isn’t it?
Screen name trick in Rails routes
Posted by Rajesh Shetty
on November 07, 2007
Trackbacks
Use this link to trackback from your own site.
Comments
You must be logged in to leave a response.