From 6b2db3ae26edb5d83149224ea98c991afe63d204 Mon Sep 17 00:00:00 2001 From: Paul Hinze Date: Thu, 20 Jun 2024 19:44:27 -0500 Subject: [PATCH] Use with_tenant in ActiveJob extension Implements the suggestion from https://github.com/ErwinM/acts_as_tenant/issues/328#issuecomment-1941985104 --- lib/acts_as_tenant/active_job_extensions.rb | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) 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