Module: ActiveRecord::Tenanted::Associations

Defined in:
lib/active_record/tenanted/associations.rb

Overview

Tenant context is checked when an association reads or writes the database, and not when the Association object is created. Serializers create associations to dump and restore their targets without ever going near a connection, and must not be tripped up by the check.

klass is resolved at both of these seams, so a polymorphic association is checked against the class it actually points at rather than being presumed tenanted.

Instance Method Summary collapse

Instance Method Details

#scopeObject

Every query built on behalf of an association funnels through here, including the ones issued by a collection proxy that has outlived the tenant context it was created in.



14
15
16
17
# File 'lib/active_record/tenanted/associations.rb', line 14

def scope
  ensure_owner_tenant_context_safety
  super
end