diff --git a/Pearlception/app/models/user.rb b/Pearlception/app/models/user.rb index 486d2eb..1c27f7e 100644 --- a/Pearlception/app/models/user.rb +++ b/Pearlception/app/models/user.rb @@ -5,10 +5,12 @@ class User < ApplicationRecord # :confirmable, :lockable, :timeoutable and :omniauthable devise :database_authenticatable, :registerable, :recoverable, :rememberable, :trackable, :validatable - + def after_database_authentication if !self.admin Apartment::Tenant.switch!(Company.find(self.company_id).company_name.gsub(/'/,'').gsub(/\s/,'')) + else + Apartment::Tenant.switch! end end end