Ask A Question

Notifications

You’re not receiving notifications from this thread.

Screencast Request: Authorization with ActionCable

Drazen asked in Site Feedback

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.

Reply

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

Reply

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.

Reply

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.

Reply

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.

Reply

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.

Reply
Join the discussion
Create an account Log in

Want to stay up-to-date with Ruby on Rails?

Join 86,946+ developers who get early access to new tutorials, screencasts, articles, and more.

    We care about the protection of your data. Read our Privacy Policy.