Sha256: b22f1005b784a1e21036ff47f2d049897d61af06ebb9f0b84d9a2165cabed5b2

Contents?: true

Size: 800 Bytes

Versions: 23

Compression:

Stored size: 800 Bytes

Contents

ActsAsTenant.configure do |config|
  config.require_tenant = lambda do |options|
    Current.namespace.present? || !options[:model].in?([User, UserAccount, Email, EmailLog])
  end

  # Customize the query for loading the tenant in background jobs
  # config.job_scope = ->{ all }
end

SET_TENANT_PROC = lambda do
  if defined?(Rails::Console)
    puts "> ActsAsTenant.current_tenant = Account.first"
    ActsAsTenant.current_tenant = Account.first
  end
end

Rails.application.configure do
  if Rails.env.development?
    # Set the tenant to the first account in development on load
    config.after_initialize do
      SET_TENANT_PROC.call
    end

    # Reset the tenant after calling 'reload!' in the console
    ActiveSupport::Reloader.to_complete do
      SET_TENANT_PROC.call
    end
  end
end

Version data entries

23 entries across 23 versions & 1 rubygems

Version Path
pg_rails-7.6.0 pg_engine/config/initializers/acts_as_tenant.rb
pg_rails-7.5.7 pg_engine/config/initializers/acts_as_tenant.rb
pg_rails-7.5.6 pg_engine/config/initializers/acts_as_tenant.rb