localhost:3000/login 显示下面的错误提示。
Routing Error
No route matches {:action=>"destroy", :controller=>"sessions"}
Try running rake routes for more information on available routes.
请问这是什么情况?SessionsController 有定义 destroy 这个 action 呀 PS:这是我跟着 Ruby on Rails Tutorial 写的一个小项目。StackOverflow 上貌似也有人提问,不过回答好像没看明白。貌似没正解
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
login /login(.:format) sessions#new
logout DELETE /logout(.:format) sessions#destroy
help /help(.:format) pages#help
about /about(.:format) pages#about
contact /contact(.:format) pages#contact
home /home(.:format) pages#home
comics /comics(.:format) pages#comics
animation /animation(.:format) pages#animation
root / pages#home
routes.rb 如下
resources :sessions, only: [:new, :create, :destroy]
match '/signup', to: 'users#new'
match '/login', to: 'sessions#new'
match '/logout', to: 'sessions#destroy', via: :delete