'How to configure acts_as_tenant gem with ActionCable in rails7
I'm working on a project with I use ActionCable, at the moment I'm learning about acts_as_tenant gem.
I implement it in the project, but my WebSockets don't work.
If I'm logged in subdomain1, and send data by the ActionCable on subdomain2, I receive information in subdomain1.
I need, if are you logged in subdomain1, you receive only data send in subdomain1.
How do I do that? Some Idea?
Solution 1:[1]
I haven't tried it, but according to https://docs.stimulusreflex.com/rtfm/authentication#multi-tenant-applications, you must set ActsAsTenant.current_tenant
at your ApplicationCable::Connection#connect
.
module ApplicationCable
class Connection < ActionCable::Connection::Base
identified_by :current_user
def connect
self.current_user = env["warden"].user
ActsAsTenant.current_tenant = current_user.account
end
end
end
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|---|
Solution 1 | tmaier |