views:

82

answers:

2

I am working on my personal site with RoR. I searched and read books. But I cannot figure out.

How Can I configure routes.rb for xxxxx.com/:id?

For example: twitpic.com's image url or short url is "http://twitpic.com/11u1cy".

+2  A: 
map.connect ':id', :controller => :your_controller, :action => :show
Brad G.
A: 

I'm assuming what you mean is that you want a URL like http://example.com/123 to load http://example.com/mymodel/123. If that is the case, put this at the end of your routes:

map.mymodel_id '/:id', :controller => 'mymodels', :action => 'show', :requirements => { :id => /\d+/}
Jimmy Cuadra