2

I am setting up devise auth gem on my app. In configuring the sign out link I am using

= link_to "Sign out", destroy_user_session_path, :method => :delete

this renders as

<a data-method="delete" href="/users/sign_out" rel="nofollow">Sign out</a>

When I run rake routes, the destroy session path is listed:

destroy_user_session_path DELETE /users/sign_out(.:format) devise/sessions#destroy

However, I am getting a No route matches [GET] "/users/sign_out" when clicking the link...what am I doing wrong here? It doesn't seem to add up.

Melbourne2991
  • 9,735
  • 10
  • 38
  • 79
  • 5
    make sure that you have jQuery in your app and that js is enable on your browser – MZaragoza Oct 27 '13 at 06:10
  • not that you want to do this but in `config/initializers/devise.rb` look for `config.sign_out_via = :delete` you can change that to `:get` – MZaragoza Oct 27 '13 at 06:11
  • this is solution for you: [devise](http://stackoverflow.com/questions/6567863/no-route-matches-get-users-sign-out) – Thanh Oct 27 '13 at 06:30

1 Answers1

0

Adding this to my <head> seems to have fixed the problem.

It seems there are similar answers to this question but they state you should add javascript_include_tag :default this didn't work for me, however "application" did.

<!--default javascript-->
<%= javascript_include_tag "application" %>

<!--csrf meta tags-->
<%= csrf_meta_tag %>
Melbourne2991
  • 9,735
  • 10
  • 38
  • 79
  • @Dschee The reason it didn't work for you is because you don't have jQuery in your application.js This is actually a fairly bad answer, it highlights a solution that would work for majority of people since jQuery is included in application.js by default, but does not explain why it works. – Reza Shirazian Dec 22 '15 at 09:21
  • @RezaShirazian: Would you mind to improve it then? :) – Jeehut Dec 22 '15 at 10:24