mirror of
https://github.com/oonyeje/Pearlception_Website_RoR.git
synced 2025-12-25 11:47:41 +00:00
- When creating a new company as an admin, a new database containing models for Runs, Grades, Results, Machines, and Oysters is migrated and created - When a user registers, they are automatically switched to their company's db in the server - When a user signs in they are also automatically swithched
17 lines
515 B
Ruby
17 lines
515 B
Ruby
class User < ApplicationRecord
|
|
belongs_to :company
|
|
has_many :runs
|
|
# Include default devise modules. Others available are:
|
|
# :confirmable, :lockable, :timeoutable and :omniauthable
|
|
devise :database_authenticatable, :registerable,
|
|
:recoverable, :rememberable, :trackable, :validatable
|
|
|
|
def after_database_authentication
|
|
binding.pry
|
|
if !self.admin
|
|
binding.pry
|
|
Apartment::Tenant.switch!(Company.find(self.company_id).company_name.gsub(/'/,'').gsub(/\s/,''))
|
|
end
|
|
end
|
|
end
|