0
漂亮的標準鏈接:Rails&Devise:destroy_user_session_path去用戶#顯示?
<li><%= link_to 'Log Out', destroy_user_session_path(current_user) %></li>
耙路線:
destroy_user_session DELETE /users/sign_out(.:format) devise/sessions#destroy
的routes.rb:
devise_for :users, :controllers => { omniauth_callbacks: "users/omniauth_callbacks", sessions: "users/sessions" }
用戶/ sessions_controller.rb:
類用戶:: SessionsController < Devise :: SessionsController
def destroy
binding.pry
cookies.delete(:auth_token)
flash[:notice] = "Successfully Logged Out"
redirect_to new_session_path
end
end
binding.pry甚至沒有被調用。鏈接將我帶到網址/users/sign_out
,但視圖是Users#show。
任何想法?
請顯示處理會話的控制器功能#destroy – hamitron
嗨@hamitron我加了一些編輯來澄清 –