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

前端 未结 19 1483
谎友^
谎友^ 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:46

    We still can use :method => :delete in my code, like that

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

    The reason i think we fail to load javascript that include jquery, make sure

    = javascript_include_tag "application" (haml- you can use html too)
    

    to include jquery-ui and jquery-ujs. So if it still error, i suggest to change rails gem in GEMFILE to version 3.2.6 and call bundle update to update gems. It works for me!

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

    I am using rails version 5. I encounter this problem also. The simple fix I did was to changing the devise configuration in initializes to the default.

    From :

    config.sign_out_via = :get
    

    To :

    config.sign_out_via = :delete
    
    0 讨论(0)
  • 2020-12-04 18:49

    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 :)

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

    It happens only on windows.. Add the following thing to your Application.html.erb file.

    devise_for :users

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

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

    FWIW I have also run into this problem. Have looked into all of the suggested answers however the only one which worked was to foto open routes.rb and comment out the following line:

    devise_for :users
    

    Below that, add the following line:

    devise_for :users do get '/users/sign_out' => 'devise/sessions#destroy' end
    
    0 讨论(0)
  • 2020-12-04 18:53

    The problem begins with rails 3.1 in assets/javascript/. Just look for application.js, and if the file doesn't exist, create a file with that name. I don't know why my file disappears or never was created on rails new app... that file is the instance for jquery.

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