0

I've looked through all of the post on this problem, but none of the solutions seem to work for me. I hope I'm not missing something obvious, but I'm new to rails and nothing is working.

I get this error when trying to sign out with devise

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

Here's my header

<%= stylesheet_link_tag    'application', media: 'all', 'data-turbolinks-track' => true %>
<%= javascript_include_tag 'application', 'data-turbolinks-track' => true %>
<%= csrf_meta_tags %>

This is the line that's giving me problems, but all my other lines work fine

<li><%= link_to 'Sign out', destroy_user_session_path, :method => :delete %></li>

And my application.js looks good

//= require jquery
//= require jquery_ujs
//= require turbolinks

Devise is setup to logout via

config.sign_out_via = :delete

rake routes gives me

Prefix Verb   URI Pattern                    Controller#Action
    new_user_session GET    /users/sign_in(.:format)       devise/sessions#new
        user_session POST   /users/sign_in(.:format)       devise/sessions#create
destroy_user_session DELETE /users/sign_out(.:format)      devise/sessions#destroy
       user_password POST   /users/password(.:format)      devise/passwords#create
   new_user_password GET    /users/password/new(.:format)  devise/passwords#new
  edit_user_password GET    /users/password/edit(.:format) 
PATCH  /users(.:format)               devise/registrations#update
                     PUT    /users(.:format)               devise/registrations#update
                     DELETE /users(.:format)               devise/registrations#destroy
               links GET    /links(.:format)               links#index
                     POST   /links(.:format)               links#create
            new_link GET    /links/new(.:format)           links#new
           edit_link GET    /links/:id/edit(.:format)      links#edit
                link GET    /links/:id(.:format)           links#show
                     PATCH  /links/:id(.:format)           links#update
                     PUT    /links/:id(.:format)           links#update
                     DELETE /links/:id(.:format)           links#destroy
                root GET    /                              links#index

I'm not sure where the problem lies and don't know what else to try.

nmares12
  • 15
  • 1
  • 7
  • possible duplicate of [No route matches \[GET\] "/users/sign\_out"](http://stackoverflow.com/questions/6567863/no-route-matches-get-users-sign-out) – Nobita Jan 24 '15 at 18:30
  • I tried all of those solutions and none of them worked. It hasn't been active for awhile, so I decided to create a new question – nmares12 Jan 24 '15 at 19:05
  • Have you tried restarting your server since installing Devise? Also what does running 'rake routes' output? – trosborn Jan 24 '15 at 19:47
  • I have and it doesn't work. I updated the question to show what 'rake routes' outputs – nmares12 Jan 24 '15 at 20:36

1 Answers1

4

Try adjusting devise.rb to the following:

config.sign_out_via = :get

You will need to restart your rails server for the configuration to apply properly.

AytanLeibowitz
  • 519
  • 2
  • 8
  • Been using devise for years and this bug came up after switching to rails 4.2 from 4.1. Changing the method worked. – Austio Feb 07 '15 at 13:02
  • 1
    http://stackoverflow.com/questions/9898892/unable-to-sign-out-in-a-rails-app-using-devise-gem-no-route-matches-users-sig – Austio Feb 07 '15 at 13:03
  • @nmares12 Just remember to not use `
  • :delete %>
  • ` in te view while `config.sign_out_via = :get` – Rômulo Collopy Jun 13 '17 at 22:10