Skip to content

Instantly share code, notes, and snippets.

View matedemorphy's full-sized avatar

matedemorphy

View GitHub Profile
@matedemorphy
matedemorphy / connection.rb
Created June 7, 2020 05:20 — forked from palkan/connection.rb
Action/AnyCable + Apartment
module ApplicationCable
class Connection < ActionCable::Base::Connection
# we need to keep tenant information for subsequent messages,
# so let's store it as an identifier
identified_by :tenant
def connect
# assuming you store current tenant in session
self.tenant = request.session[:current_tenant]
reject_unauthorized_connection unless tenant