Alex Rivera | Logout

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

Asked 2011-07-04T06:07:18.287
42

Here is my actual error: No route matches [GET] "/members/sign_out" Since most people will use "users" I thought it would be more helpful to have that in the title. At any rate, I am essential unable to logout. I can successfully edit my member profile.

I am using devise 1.4.2 and Rails 3.1.0.rc4. Also, I have generated two separate devise models - one called "members" and the other called "admins". I was able to register and log into both of them (simultaneously) by manually navigating to the correct URL path (i.e., localhost:3000/admins/sign_in/). I created some links within my application.html.haml layout file by following this RailsCast on Devise. I am aware that it only addresses signin/signout links for "members."

If I click on the signout link I get the above error. This occurs if I manually navigate to either signout URL (i.e., localhost:3000/admins/sign_out/).

Can someone tell me why this is happening? Below are the various related files. And of course, I'm a newbie...

rake routes output:

    j(film_repo)$ rake routes
        new_member_session GET    /members/sign_in(.:format)       {:action=>"new", :controller=>"devise/sessions"}
            member_session POST   /members/sign_in(.:format)       {:action=>"create", :controller=>"devise/sessions"}
    destroy_member_session DELETE /members/sign_out(.:format)      {:action=>"destroy", :controller=>"devise/sessions"}
           member_password POST   /members/password(.:format)      {:action=>"create", :controller=>"devise/passwords"}
       new_member_password GET    /members/password/new(.:format)  {:action=>"new", :controller=>"devise/passwords"}
      edit_member_password GET    /members/password/edit(.:format) {:action=>"edit", :controller=>"devise/passwords"}
                           PUT    /members/password(.:format) 
Edit
Report

3 Answers

64

You can end a session via get by changing the devise configuration in initializers.

# The default HTTP method used to sign out a resource. Default is :delete.
config.sign_out_via = :get

Just open the link and your session is removed.

answered 2011-09-11T19:00:04.150
3

Maybe that will help somebody. Upgraded from Rails 3.0 to 3.1 and found this problem. This fixed it for me:

routes.rb:
devise_for: users

devise.rb:
config.sign_out_via = :delete

application.html.erb:

<%= javascript_include_tag "application" %>     

* not :defaults

_login_items.html.erb:

<%= link_to('Logout', destroy_user_session_path, :method => :delete) %>

app/assets/javascripts/application.js

//= require jquery
//= require jquery-ui
//= require jquery_ujs
//= require_tree .

and I had in javascript/ jquery.js, jquery_ujs.js from 3.0 version that I've removed.

answered 2011-12-13T23:19:37.333
3

You may have removed assets/javascripts/*

Run rails generate jquery:install --ui this will generate all the javascripts as shown below

xxxx@xxxxx:~/Projects/Rails_apps/rtest$ rails generate jquery:install --ui
      remove  public/javascripts/prototype.js
      remove  public/javascripts/effects.js
      remove  public/javascripts/dragdrop.js
      remove  public/javascripts/controls.js
     copying  jQuery (1.7.1)
      create  public/javascripts/jquery.js
      create  public/javascripts/jquery.min.js
     copying  jQuery UI (1.8.16)
      create  public/javascripts/jquery-ui.js
      create  public/javascripts/jquery-ui.min.js
     copying  jQuery UJS adapter (822920)
      remove  public/javascripts/rails.js
      create  public/javascripts/jquery_ujs.js

Go to your layout e.g application.html.erb and edit <%= javascript_include_tag :all %>

That worked for me :)

answered 2011-12-29T17:13:33.290

Your Answer