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

build_settings_entry, #generate_schedule, #sync_schedule

Methods included from PandaPal::OrganizationConcerns::SettingsValidation

#settings_structure, #validate_settings

Instance Method Details

#encryption_keyObject



34
35
36
37
38
39
40
41
42
# File 'app/models/panda_pal/organization.rb', line 34

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



44
45
46
47
48
49
50
# File 'app/models/panda_pal/organization.rb', line 44

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