Skip to content

Commit 217ef99

Browse files
committed
Support global_records_identifier configuration
1 parent 8e8f9de commit 217ef99

File tree

2 files changed

+6
-2
lines changed

2 files changed

+6
-2
lines changed

lib/acts_as_tenant/configuration.rb

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
module ActsAsTenant
22
class Configuration
3-
attr_writer :require_tenant, :pkey
3+
attr_writer :require_tenant, :pkey, :global_records_identifier
44

55
def require_tenant
66
@require_tenant ||= false
@@ -10,6 +10,10 @@ def pkey
1010
@pkey ||= :id
1111
end
1212

13+
def global_records_identifier
14+
@global_records_identifier ||= nil
15+
end
16+
1317
def job_scope
1418
@job_scope || ->(relation) { relation.all }
1519
end

lib/acts_as_tenant/model_extensions.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ def acts_as_tenant(tenant = :account, scope = nil, **options)
2323

2424
if ActsAsTenant.current_tenant
2525
keys = [ActsAsTenant.current_tenant.send(pkey)].compact
26-
keys.push(nil) if options[:has_global_records]
26+
keys.push(ActsAsTenant.global_records_identifier) if options[:has_global_records]
2727

2828
if options[:through]
2929
query_criteria = {options[:through] => {fkey.to_sym => keys}}

0 commit comments

Comments
 (0)