Skip to content

Commit

Permalink
Use with_tenant in ActiveJob extension
Browse files Browse the repository at this point in the history
Implements the suggestion from ErwinM#328 (comment)
  • Loading branch information
phinze authored Jun 21, 2024
1 parent 7e3bd8a commit 13c9fd1
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions lib/acts_as_tenant/active_job_extensions.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,10 @@ 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
end
tenant = tenant_global_id ? GlobalID::Locator.locate(tenant_global_id) : nil

ActsAsTenant.with_tenant tenant do
super
end
end
end

0 comments on commit 13c9fd1

Please sign in to comment.