我的 Rails routes.rb 中有以下内容:
resource :sign_up, only: [:new, :create]
resources :users
get 'users/activate/:token' => 'users#activate', as: 'activate_user'
这给了我以下路线:
Prefix Verb URI Pattern Controller#Action
sign_up POST /sign_up(.:format) sign_ups#create
new_sign_up GET /sign_up/new(.:format) sign_ups#new
users GET /users(.:format) users#index
POST /users(.:format) users#create
new_user GET /users/new(.:format) users#new
edit_user GET /users/:id/edit(.:format) users#edit
user GET /users/:id(.:format) users#show
PATCH /users/:id(.:format) users#update
PUT /users/:id(.:format) users#update
DELETE /users/:id(.:format) users#destroy
activate_user GET /users/activate/:token(.:format) users#activate
我想摆脱get 'users/activate/:token' ...
路线并改用嵌套或范围,但我无法弄清楚。有没有办法做到这一点?
谢谢!