Ruby Name Routes with permalinks and static pages
I have several static pages and a couple of dynamic pages. Static pages are under the "Info" controller. Dynamic pages are under "products". I want to access "products" from their :permalink I can only get map.info or map.products to work but not both.
ActionController::Routing::Routes.draw do |map|
map.resources :pr开发者_如何学编程oducts
map.resources :info
map.root :controller => "products"
map.info ':action', :controller => "info"
map.products ':permalink', :controller => 'products', :action => 'show'
map.connect ':controller/:action/:id'
map.connect ':controller/:action/:id.:format'
end
Let's say you go to http://yoursite.com/something
How can the routes determine if it's a product or info page? It can't, and that's why it won't work. You have to put one of them under a namespace of some sort.
map.info ':action', :controller => "info"
map.products '/products/:permalink', :controller => 'products', :action => 'show'
精彩评论