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
resources :users
and devise_for :users
are conflict so
try below code:
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
You've done everything right. The only missing thing is the :method => :delete
call. This is rails specific and you need rails-ujs or for older rails version jquery_ujs to make it work.
Add this to your app/assets/javascripts/application.js:
# for rails 5.1 or higher
//= require rails-ujs
# for rails 5.0 or lower
//= require jquery
//= require jquery_ujs
If you don't add this, the method: :delete
call will not work. If you don't want to use it at all, then change sign_out to work with GET.
Change or add this to your config/initializers/devise.rb:
config.sign_out_via = :get
If it's still not working, then you have the wrong order in your config/routes.rb file. devise_for :users
must be before resources :users
:
devise_for :users
resources :users