Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

devise No route matches [GET] "/users/sign_out"

I am trying to use Desive authentication.

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; 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; No route matches [GET] "/users/sign_out".

As an aside, I'm currently running Ruby-2.0.0-p195, and Rails 3.2.13

like image 739
Efe Avatar asked Nov 29 '22 08:11

Efe


2 Answers

Use method DELETE

<%= link_to "sign out", destroy_user_session_path, method: :delete %>
like image 193
sites Avatar answered Dec 05 '22 14:12

sites


You need to pass "method: delete" to send as DELETE request. If you dont set "method: delete", then it will be sent as GET request.

<%= link_to "Sign Out" ,destroy_user_session_path, method: :delete %>
like image 45
kengo Avatar answered Dec 05 '22 15:12

kengo