Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for setting the current tenant in an ActionCable context #280

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

scarhand
Copy link
Contributor

Allows you to use set_current_tenant_through_filter, set_current_tenant_by_subdomain_or_domain and set_current_tenant_by_subdomain in ActionCable channels, in a similar vein as ActionControllers.

E.g.:

class SpecSubdomainOrDomainChannel < ApplicationCable::Channel
  set_current_tenant_by_subdomain_or_domain

  def subscribed
    reject if params[:room_id].nil?
  end

  def whoami
    transmit current_tenant.name
  end
end

Haven't made any changes to the README, as I wasn't sure where to put it :)

@excid3
Copy link
Collaborator

excid3 commented Apr 15, 2022

@scarhand Looks like ActiveSupport.on_load(:action_cable_channel) wasn't added until Rails 6, which is the cause for the failures on Rails 5.2.

Rails 5.2 is EOL on June 1st, 2022, so we can't really drop support for it yet I feel like.

Maybe we can do a different method for Rails 5, like a config.to_prepare block or something?

@excid3 excid3 self-assigned this Apr 15, 2022
@scarhand
Copy link
Contributor Author

Looks like the PR is about a month too early then ;)
I'll see if config.to_prepare can be used, or if there's something else that works with Rails 5(.2).

@excid3
Copy link
Collaborator

excid3 commented Apr 21, 2022

If there's nothing easy, we can wait on Rails 5.2 to be EOL and update the required versions here soon.

@ziadsawalha
Copy link
Contributor

ziadsawalha commented Dec 12, 2023

@excid3 Rails 5.2 is now EOL. Is this PR now possible to merge?

Or does it need to work with class Connection < ActionCable::Connection::Base now?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants