How to configure acts_as_tenant gem with ActionCable in rails7

189 Views Asked by At

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?

1

There are 1 best solutions below

0
On

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