diff --git a/lib/acts_as_tenant/active_job_extensions.rb b/lib/acts_as_tenant/active_job_extensions.rb index a0e3b42..0ea7950 100644 --- a/lib/acts_as_tenant/active_job_extensions.rb +++ b/lib/acts_as_tenant/active_job_extensions.rb @@ -6,8 +6,11 @@ def serialize def deserialize(job_data) tenant_global_id = job_data.delete("current_tenant") - ActsAsTenant.current_tenant = tenant_global_id ? GlobalID::Locator.locate(tenant_global_id) : nil - super + tenant = tenant_global_id ? GlobalID::Locator.locate(tenant_global_id) : nil + + ActsAsTenant.with_tenant tenant do + super + end end end end