简体   繁体   中英

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?

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM