Add auto switch to default db for admin user

This commit is contained in:
Okechi Onyeje 2017-02-23 12:18:44 -05:00
parent 4783f37dcc
commit eab7216058

View File

@ -5,10 +5,12 @@ class User < ApplicationRecord
# :confirmable, :lockable, :timeoutable and :omniauthable # :confirmable, :lockable, :timeoutable and :omniauthable
devise :database_authenticatable, :registerable, devise :database_authenticatable, :registerable,
:recoverable, :rememberable, :trackable, :validatable :recoverable, :rememberable, :trackable, :validatable
def after_database_authentication def after_database_authentication
if !self.admin if !self.admin
Apartment::Tenant.switch!(Company.find(self.company_id).company_name.gsub(/'/,'').gsub(/\s/,'')) Apartment::Tenant.switch!(Company.find(self.company_id).company_name.gsub(/'/,'').gsub(/\s/,''))
else
Apartment::Tenant.switch!
end end
end end
end end