开发者

Rails: How can I configure to routes.rb for /:id?

开发者 https://www.devze.com 2022-12-19 16:20 出处:网络
I am working开发者_开发技巧 on my personal site with RoR. I searched and read books. But I cannot figure out.

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+/}
0

精彩评论

暂无评论...
验证码 换一张
取 消