Module: TenantKit::ControllerConcern
- Extended by:
- ActiveSupport::Concern
- Defined in:
- lib/tenant_kit/controller_concern.rb
Overview
Mixed into ActionController::Base and ActionController::API (via the
railtie). Provides class-level helpers that install a before_action to
resolve and set the current tenant for each request. CurrentAttributes
resets the tenant automatically between requests.
Class Method Summary collapse
-
.tenant_model_for(tenant_name) ⇒ Class
Resolves the tenant model class for the given (optional) name.
Instance Method Summary collapse
-
#current_tenant ⇒ Object?
The current tenant for this request.
-
#current_tenant=(tenant) ⇒ Object?
Sets the current tenant for this request.
Class Method Details
.tenant_model_for(tenant_name) ⇒ Class
Resolves the tenant model class for the given (optional) name.
63 64 65 66 67 |
# File 'lib/tenant_kit/controller_concern.rb', line 63 def self.tenant_model_for(tenant_name) return TenantKit.config.tenant_model if tenant_name.nil? tenant_name.to_s.camelize.constantize end |