0

I'm using devise and I'm struggling to log out from inside a partial.

<%= link_to "Bye", destroy_user_session_path, :method => :delete %>

That's the code. I have exactly the same code on the homepage and it works.

I get this error:

No route matches [GET] "/users/sign_out"
ItsJoeTurner
  • 497
  • 2
  • 7
  • 24
  • just curious, from inside that partial can you check the current user? `<% if user_signed_in? %>` –  Mar 21 '13 at 19:33
  • Yes. That's something I do inside the same partial, and it works. – ItsJoeTurner Mar 21 '13 at 19:39
  • Check the code for that link to make sure that your `:method => :delete` is working because the error is stating your code called it as via `GET`, what won't work –  Mar 21 '13 at 19:46
  • Have you tried `destroy_user_session_url` instead of `.._path`? – ted Mar 21 '13 at 20:08

1 Answers1

0

I'm assuming this is not a problem with it being in a partial. If you look closely, you are setting the method => delete, but yet it's calling a GET method rather than a DELETE method and the GET method does not exist.

If i remember correctly you need to have this in your layout.

<%= javascript_include_tag 'application' %>  
Catfish
  • 18,876
  • 54
  • 209
  • 353