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?
精彩评论