diff --git a/app/models/user.rb b/app/models/user.rb index 60e9df1..f113f3b 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -19,7 +19,8 @@ class User < ApplicationRecord validates :email, presence: true, uniqueness: true, length: {maximum: type_for_attribute(:email).limit} - validates :unconfirmed_email, length: {maximum: type_for_attribute(:unconfirmed_email).limit} + validates :unconfirmed_email, + length: {maximum: type_for_attribute(:unconfirmed_email).limit} def to_s email diff --git a/config/routes.rb b/config/routes.rb index b40d356..6218a39 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -20,8 +20,14 @@ Rails.application.routes.draw do end end - devise_for :users, path: '', path_names: {registration: 'profile'}, - controllers: {registrations: :registrations} + # Devise does not handle properly models that require database access during loading. + # https://github.com/heartcombo/devise/issues/5786 + connection = ActiveRecord::Base.connection + if connection.schema_version && connection.table_exists?(:users) + devise_for :users, path: '', path_names: {registration: 'profile'}, + controllers: {registrations: :registrations} + end + resources :users, only: [:index, :show, :update] do member { get :disguise } collection { get :revert }