diff --git a/lib/acts_as_tenant/configuration.rb b/lib/acts_as_tenant/configuration.rb index e75ebcf..a9ea9e3 100644 --- a/lib/acts_as_tenant/configuration.rb +++ b/lib/acts_as_tenant/configuration.rb @@ -1,6 +1,6 @@ module ActsAsTenant class Configuration - attr_writer :require_tenant, :pkey + attr_writer :require_tenant, :pkey, :global_records_identifier def require_tenant @require_tenant ||= false @@ -10,6 +10,10 @@ def pkey @pkey ||= :id end + def global_records_identifier + @global_records_identifier ||= nil + end + def job_scope @job_scope || ->(relation) { relation.all } end diff --git a/lib/acts_as_tenant/model_extensions.rb b/lib/acts_as_tenant/model_extensions.rb index 053b9b8..9c253fe 100644 --- a/lib/acts_as_tenant/model_extensions.rb +++ b/lib/acts_as_tenant/model_extensions.rb @@ -23,7 +23,7 @@ def acts_as_tenant(tenant = :account, scope = nil, **options) if ActsAsTenant.current_tenant keys = [ActsAsTenant.current_tenant.send(pkey)].compact - keys.push(nil) if options[:has_global_records] + keys.push(ActsAsTenant.global_records_identifier) if options[:has_global_records] if options[:through] query_criteria = {options[:through] => {fkey.to_sym => keys}}