Class: PandaPal::Organization

Inherits:
ActiveRecord::Base
  • Object
show all
Includes:
PandaPal::OrganizationConcerns::SettingsValidation, PandaPal::OrganizationConcerns::TaskScheduling
Defined in:
app/models/panda_pal/organization.rb

Instance Method Summary collapse

Methods included from PandaPal::OrganizationConcerns::TaskScheduling

#generate_schedule, #sync_schedule

Methods included from PandaPal::OrganizationConcerns::SettingsValidation

#settings_structure, #validate_settings

Instance Method Details

#encryption_keyObject



31
32
33
34
35
36
37
38
39
# File 'app/models/panda_pal/organization.rb', line 31

def encryption_key
  # production environment might not have loaded secret_key_base yet.
  # In that case, just read it from env.
  if (Rails.application.secrets.secret_key_base)
    Rails.application.secrets.secret_key_base[0,32]
  else
    ENV["SECRET_KEY_BASE"][0,32]
  end
end

#switch_tenant(&block) ⇒ Object



41
42
43
44
45
46
47
# File 'app/models/panda_pal/organization.rb', line 41

def switch_tenant(&block)
  if block_given?
    Apartment::Tenant.switch(name, &block)
  else
    Apartment::Tenant.switch!(name)
  end
end