MichaelHartlのRubyonRails Tutorial 2nd Editionをフォローしていて、本のサインイン/サインアウトのセクションに到達しました。
これまでのところ、新しいユーザー(または私の場合は家主)を作成し、新しい資格情報でログインできます。私が抱えている問題は、サインアウトするときです。「サインアウト」をクリックすると、次のようなルートエラーが発生します。
[GET]"/signout"に一致するルートはありません
以下はコードスニペットです。どんな助けでも大歓迎です!
レーキルート出力
landlords GET /landlords(.:format) landlords#index
POST /landlords(.:format) landlords#create
new_landlord GET /landlords/new(.:format) landlords#new
edit_landlord GET /landlords/:id/edit(.:format) landlords#edit
landlord GET /landlords/:id(.:format) landlords#show
PUT /landlords/:id(.:format) landlords#update
DELETE /landlords/:id(.:format) landlords#destroy
properties GET /properties(.:format) properties#index
POST /properties(.:format) properties#create
new_property GET /properties/new(.:format) properties#new
edit_property GET /properties/:id/edit(.:format) properties#edit
property GET /properties/:id(.:format) properties#show
PUT /properties/:id(.:format) properties#update
DELETE /properties/:id(.:format) properties#destroy
sessions POST /sessions(.:format) sessions#create
new_session GET /sessions/new(.:format) sessions#new
session DELETE /sessions/:id(.:format) sessions#destroy
root / content_pages#home
content_pages_home GET /content_pages/home(.:format) content_pages#home
help /help(.:format) content_pages#help
questions /questions(.:format) content_pages#questions
signup /signup(.:format) landlords#new
signin /signin(.:format) sessions#new
signout DELETE /signout(.:format) sessions#destroy
ルート.rbファイル
resources :landlords
resources :properties
resources :sessions, only: [:new, :create, :destroy]
root :to => 'content_pages#home'
get "content_pages/home"
match '/help', to: 'content_pages#help'
match '/questions', to: 'content_pages#questions'
match '/signup', to: 'landlords#new'
match '/signin', to: 'sessions#new'
match '/signout', to: 'sessions#destroy', via: :delete
サインアウトへのリンク
<%= link_to "Signout", signout_path, method: "delete" %>
セッションコントローラー
def destroy
sign_out
redirect_to root_path
end