mirror of
https://github.com/oonyeje/Pearlception_Website_RoR.git
synced 2025-12-25 03:37:40 +00:00
20 lines
575 B
Ruby
20 lines
575 B
Ruby
class User < ApplicationRecord
|
|
belongs_to :company
|
|
has_many :runs
|
|
# Include default devise modules. Others available are:
|
|
# :confirmable, :lockable, :timeoutable and :omniauthable
|
|
|
|
validates :email, presence: true, uniqueness: true
|
|
|
|
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
|