我有这个
devise_for :users
resources :sites do
resources :users
get 'companies/search'
end
root :to => "welcome#index"
end
路线看起来像这样
site_users GET /sites/:site_id/users(.:format) users#index
POST /sites/:site_id/users(.:format) users#create
new_site_user GET /sites/:site_id/users/new(.:format) users#new
edit_site_user GET /sites/:site_id/users/:id/edit(.:format) users#edit
site_user GET /sites/:site_id/users/:id(.:format) users#show
PUT /sites/:site_id/users/:id(.:format) users#update
DELETE /sites/:site_id/users/:id(.:format) users#destroy
site_companies_search GET /sites/:site_id/companies/search(.:format) sites/:site_id/companies#search
sites GET /sites(.:format) sites#index
POST /sites(.:format) sites#create
new_site GET /sites/new(.:format) sites#new
edit_site GET /sites/:id/edit(.:format) sites#edit
site GET /sites/:id(.:format) sites#show
PUT /sites/:id(.:format) sites#update
DELETE /sites/:id(.:format) sites#destroy
root / welcome#index
但我想知道是否有办法拥有这样的路线
site_users GET /:site_id/users(.:format) users#index
POST /:site_id/users(.:format) users#create
new_site_user GET /:site_id/users/new(.:format) users#new
edit_site_user GET /:site_id/users/:id/edit(.:format) users#edit
site_user GET /:site_id/users/:id(.:format) users#show
PUT /:site_id/users/:id(.:format) users#update
DELETE /:site_id/users/:id(.:format) users#destroy
没有 /sites 在 url 所以 url 来自
/sites/some_name/users
/sites/some_name/users/new
到
/some_name/users
/some_name/users/new
如果可能的话,这将清理 url