我用
rails g scaffold_controller admin/sub/Product name:string
生成crud页面,
现在我需要编写route.rb文件来映射admin_sub_product_controller,如何在rails3上写这个路由文件?
我很难编写2级命名空间映射路径
namespace admin do
resource :products
end
这只是/ admin / products的wokrs,但是对于映射admin / sub / proudcts如何写?
答案 0 :(得分:9)
namespace :admin do
namespace :sub do
resources :products
end
end
rake routes
admin_sub_products GET /admin/sub/products(.:format) {:action=>"index", :controller=>"admin/sub/products"}
POST /admin/sub/products(.:format) {:action=>"create", :controller=>"admin/sub/products"}
new_admin_sub_product GET /admin/sub/products/new(.:format) {:action=>"new", :controller=>"admin/sub/products"}
edit_admin_sub_product GET /admin/sub/products/:id/edit(.:format) {:action=>"edit", :controller=>"admin/sub/products"}
admin_sub_product GET /admin/sub/products/:id(.:format) {:action=>"show", :controller=>"admin/sub/products"}
PUT /admin/sub/products/:id(.:format) {:action=>"update", :controller=>"admin/sub/products"}
DELETE /admin/sub/products/:id(.:format) {:action=>"destroy", :controller=>"admin/sub/products"}