Efe
Efe

Reputation: 954

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

Upvotes: 4

Views: 6123

Answers (2)

kengo
kengo

Reputation: 601

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 %>

Upvotes: 6

sites
sites

Reputation: 21785

Use method DELETE

<%= link_to "sign out", destroy_user_session_path, method: :delete %>

Upvotes: 18

Related Questions