4

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

Efe
  • 944
  • 3
  • 19
  • 37

2 Answers2

18

Use method DELETE

<%= link_to "sign out", destroy_user_session_path, method: :delete %>
sites
  • 21,417
  • 17
  • 87
  • 146
6

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 %>
kengo
  • 601
  • 8
  • 19