On destroying session via Devise “Couldn't find User with 'id'=sign_out”

后端 未结 2 1851
夕颜
夕颜 2021-01-26 19:05

I\'m running Rails 5.1.2 and Ruby 2.4.0.

I\'ve created a method in the ApplicationController called require_login that checks if the user is logged in order

2条回答
  •  南方客
    南方客 (楼主)
    2021-01-26 19:32

    resources :users and devise_for :users are conflict so

    try below code:

    routes.rb

    Rails.application.routes.draw do
      root to: 'visitors#index'
      devise_for :users
      #resources :users //comment the users resources because its already used by devise_for or used some other resources for users
    
    
      get "home/index"
      get "home/minor"
      root to: 'home#index'
    
    end
    

    Additionally, in your config/initalizer/devise.rb file

    Change config.sign_out_via = :delete to config.sign_out_via = :get

提交回复
热议问题