我的 routes.rb 文件有以下内容:
Hchq::Application.routes.draw do
resources :users
resources :sessions, only: [:new, :create, :destroy]
match '/signup', to: 'users#new'
match '/signin', to: 'sessions#new'
match '/signout', to: 'sessions#destroy', via: :delete
end
当我跑步时,rake routes
我得到:
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
PUT /users/:id(.:format) users#update
DELETE /users/:id(.:format) users#destroy
sessions POST /sessions(.:format) sessions#create
new_session GET /sessions/new(.:format) sessions#new
session DELETE /sessions/:id(.:format) sessions#destroy
signup /signup(.:format) users#new
signin /signin(.:format) sessions#new
signout DELETE /signout(.:format) sessions#destroy
然而,当我去时,http://localhost:3000/signout
我得到以下信息:
在日志中我得到:ActionController::RoutingError (No route matches [GET] "/signout"):
哪个,我不应该在 /signout 路由上使用 [DELETE] 而不是 [GET] 吗?如果是这样,我该如何更改?