rob*_*kos 3 routing ruby-on-rails ruby-on-rails-3
我想要一个名为"portal"的命名空间控制器.
在这将是嵌套资源,如公司和产品.
我想要像以下路线:
/portal/:company_id/product/:id 上班
我可以得到
/portal/company/:company_id/product/:id 工作但想要消除网址中的"公司"
希望很清楚.请记住,我需要存在命名空间模块门户.
我认为你可以scope用来实现你想要的.也许是这样的:
namespace "portal" do
scope ":company_id" do
resources :products
end
end
Run Code Online (Sandbox Code Playgroud)
这将产生以下路线:
portal_products GET /portal/:company_id/products(.:format) {:action=>"index", :controller=>"portal/products"}
POST /portal/:company_id/products(.:format) {:action=>"create", :controller=>"portal/products"}
new_portal_product GET /portal/:company_id/products/new(.:format) {:action=>"new", :controller=>"portal/products"}
edit_portal_product GET /portal/:company_id/products/:id/edit(.:format) {:action=>"edit", :controller=>"portal/products"}
portal_product GET /portal/:company_id/products/:id(.:format) {:action=>"show", :controller=>"portal/products"}
PUT /portal/:company_id/products/:id(.:format) {:action=>"update", :controller=>"portal/products"}
DELETE /portal/:company_id/products/:id(.:format) {:action=>"destroy", :controller=>"portal/products"}
Run Code Online (Sandbox Code Playgroud)
编辑:意外使用的资源而不是资源.现在修复了.