开发者

Rails route for mapping records by name rather than id?

In my Rails application, I would like to route /product/productname1, /product/productname2, etc. to ProductController::index(). I don't want开发者_StackOverflow separate methods in my ProductController for each product name route.

What would my route look like?

I have

map.connect 'products/:name', :controller => 'products', :action => 'index'

But when I go to

/products/something

I get

No action responded to show. Actions: index


Does it have to do with the ordering of your routes file? eg is this coming after map.resources :products?

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜