[英]devise No route matches [GET] “/users/sign_out”
I am trying to use Desive authentication. 我正在尝试使用Desive身份验证。
Everything went smoothly until this point (sign up and sign in). 一切顺利,直到这一点(注册并登录)。
But I cannot make the sign out link work. 但我无法使签出链接工作。 I checked the destination link with
rake routes
; 我用
rake routes
检查了目的地链接; destroy_user_session DELETE /users/sign_out(.:format) devise/sessions#destroy
. destroy_user_session DELETE /users/sign_out(.:format) devise/sessions#destroy
。
But when I put <%= link_to "sign out", destroy_user_session_path %>
on the home page and clicked on the link, I received this error; 但是当我在主页上输入
<%= link_to "sign out", destroy_user_session_path %>
并点击链接时,我收到了这个错误; No route matches [GET] "/users/sign_out"
. No route matches [GET] "/users/sign_out"
。
As an aside, I'm currently running Ruby-2.0.0-p195, and Rails 3.2.13 顺便说一句,我目前正在运行Ruby-2.0.0-p195和Rails 3.2.13
使用方法DELETE
<%= link_to "sign out", destroy_user_session_path, method: :delete %>
You need to pass "method: delete" to send as DELETE request. 您需要传递“method:delete”作为DELETE请求发送。 If you dont set "method: delete", then it will be sent as GET request.
如果你没有设置“method:delete”,那么它将作为GET请求发送。
<%= link_to "Sign Out" ,destroy_user_session_path, method: :delete %>
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.