Rails: How can I configure to routes.rb for /:id?
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".
map.connect ':id', :controller => :your_controller, :action => :show
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+/}
精彩评论