No route matches [GET] “/users/sign_out”

前端 未结 19 1484
谎友^
谎友^ 2020-12-04 18:44

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 th

相关标签:
19条回答
  • 2020-12-04 18:54

    I had a similar problem, but addition of the :method=> :delete didn't work. I was able to add a new route for a the get request by commenting out the devise_for :users and adding

    devise_for :users do
      get '/users/sign_out' => 'devise/sessions#destroy'
    end
    
    0 讨论(0)
  • 2020-12-04 18:57
    = link_to "Sign out", destroy_user_session_path,:method => :delete
    

    will NOT work instead use this,

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

    should do the trick or worse case add require jquery_ujs in your application.js

    0 讨论(0)
  • 2020-12-04 18:58

    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.

    0 讨论(0)
  • 2020-12-04 18:59

    I just needed to add the

    //= require jquery
    //= require jquery_ujs
    

    to my application.js

    0 讨论(0)
  • 2020-12-04 18:59

    @creamhost say,

    devise_for :users do get '/users/sign_out' => 'devise/sessions#destroy' end
    

    but it is not correct solution for me (Rails4). I solved our problem (@Olives' answer),

    link_to :logout, destroy_member_session_path, method: :delete
    
    0 讨论(0)
  • 2020-12-04 19:04

    Had the same problem and remembered it only started happening after I decided to "clean up" my Javascript files. So I ran rails generate jquery:install --ui again and this solved it for me. (You can ignore the --ui part if you don't need JQuery UI, I suppose.)

    0 讨论(0)
提交回复
热议问题