Skip to main content

Screencast Request: Authorization with ActionCable

Site Feedback • Asked by Drazen Mokic

A cast about how to do authorization with ActionCable. Example is a Chat with multiple chat rooms and messages should only be sent to rooms / people who have access to the given chat room.


Fantastic idea. I imagine using something like Pundit with ActionCable will be really useful for this.


Yep definitely.

What approach would you take on the client side? When you have 5 chat rooms but you are only viewing one at a time, where would you store the messages of the other 4 so when you select another channel to view, you don't have to query the db every time.


It probably makes the most sense to have those on the page by in hidden divs. That way you don't have to store all those messages in memory in a hash of some sort and you can inject them on the page as HTML. They won't be visible, but you can continually still get updates for them. Everything will continue updating in realtime, you're just visually hiding everything but the active channel.

My guess would be that Slack's app works the same way when you're logged into multiple channels.


Yeah i will probably do that because i can get away with it. It's a internal chat but for public ones like Slack that wouldn't work well. Performance would be a problem when storing all of that in the DOM.

I checked out Slack and it does not have all of the chat rooms inside the DOM. There is no local storage too so my best guess is that it stores it inside a JS variable in memory and it fills a single chat room DOM node when you click the rooms.


Yeah, that makes sense given the scale of support they need to have. I bet the average user for them is connected to like 20 chat rooms in each organization, and then like most of my friends, connected as well to like 5+ organizations. That's a lot of DOM manipulation that you can postpone until later.


Login or Create An Account to join the conversation.

Subscribe to the newsletter

Join 27,623+ developers who get early access to new screencasts, articles, guides, updates, and more.

    By clicking this button, you agree to the GoRails Terms of Service and Privacy Policy.

    More of a social being? We're also on Twitter and YouTube.