Module: TenantKit::Model::BuildGuard

Defined in:
lib/tenant_kit/model.rb

Overview

Extended onto each tenant-owned model. Building a record evaluates the strict default_scope via scope_for_create; without this guard, Model.new with no current tenant would raise instead of letting presence validation report the missing tenant. We disable scoping only for the build itself — the subsequent save (and its validations) runs normally.

Instance Method Summary collapse

Instance Method Details

#new(*args, **kwargs, &block) ⇒ Object



15
16
17
# File 'lib/tenant_kit/model.rb', line 15

def new(*args, **kwargs, &block)
  TenantKit.without_tenant { super }
end