1
我正在使用RoR在我的个人网站上工作。 我搜索并阅读了书籍。但我无法弄清楚。Rails:如何配置routes.rb作为/:id?
如何为xxxxx.com/:id配置routes.rb?
例如: twitpic.com的图片网址或短url是“http://twitpic.com/11u1cy”。
我正在使用RoR在我的个人网站上工作。 我搜索并阅读了书籍。但我无法弄清楚。Rails:如何配置routes.rb作为/:id?
如何为xxxxx.com/:id配置routes.rb?
例如: twitpic.com的图片网址或短url是“http://twitpic.com/11u1cy”。
map.connect ':id', :controller => :your_controller, :action => :show
我假设你的意思是你要像http://example.com/123一个URL来加载http://example.com/mymodel/123。如果是这种情况,请将其放置在路线末端:
map.mymodel_id '/:id', :controller => 'mymodels', :action => 'show', :requirements => { :id => /\d+/}