我想为Team
提供以下资源丰富的路线:
/admin/users/teams
/admin/users/team/new
/admin/users/team/:id
etc...
使用以下路线助手
admin_teams_path
new_admin_teams_path
edit_admin_teams_path
etc...
但是我知道并使用
唯一的命名空间namespace :admin do
namespace :users do
resources :teams, except: [:index]
end
end
我只是在这些长途路线助手中加入了“用户”:
admin_users_teams_path
new_admin_users_teams_path
edit_admin_users_teams_path
答案 0 :(得分:2)
删除users
命名空间并使用路由中的path
选项:
namespace :admin, path: "admin/users" do
resources :teams, except: [:index]
end
给出以下路线:
$ rake routes
admin_teams POST /admin/users/teams(.:format) admin/teams#create
new_admin_team GET /admin/users/teams/new(.:format) admin/teams#new
edit_admin_team GET /admin/users/teams/:id/edit(.:format) admin/teams#edit
admin_team GET /admin/users/teams/:id(.:format) admin/teams#show
PATCH /admin/users/teams/:id(.:format) admin/teams#update
PUT /admin/users/teams/:id(.:format) admin/teams#update
DELETE /admin/users/teams/:id(.:format) admin/teams#destroy