# Chat rooms, on Rails, with Action Cable

**URL:** <https://metaruby.com/t/chat-rooms-on-rails-with-action-cable/528>\
**Category:** Ruby Chat\
**Created:** [June 3, 2016, 2:24am UTC](https://metaruby.com/t/chat-rooms-on-rails-with-action-cable/528 "2016-06-03T02:24:12Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![kofno](https://metaruby.com/user_avatar/metaruby.com/kofno/32/159_2.png) [@kofno](https://metaruby.com/u/kofno)\
**Post date:** [June 3, 2016, 2:24am UTC](https://metaruby.com/t/chat-rooms-on-rails-with-action-cable/528/1 "2016-06-03T02:24:13Z")

</div>

The hello world of websocket apps is the chat. This one actually creates little chat rooms you can squat in.

Built on Rails 5.rc1 using ActionCable. ActionCable was pleasant to work with, and fit into the Rails development flow _pretty_ well. I’m developing my thoughts on what I think it may mean for Rails architectures in the future. But so far, I can recommend!

> **[kofno/hullo](https://github.com/kofno/hullo)**
>
> Chat rooms... for the web... Contribute to kofno/hullo development by creating an account on GitHub.

[https://protected-tor-23673.herokuapp.com/](https://protected-tor-23673.herokuapp.com/)

---

<div class="post-metadata">

**Author:** ![danielpclark](https://metaruby.com/user_avatar/metaruby.com/danielpclark/32/823_2.png) [@danielpclark](https://metaruby.com/u/danielpclark)\
**Post date:** [June 3, 2016, 6:53pm UTC](https://metaruby.com/t/chat-rooms-on-rails-with-action-cable/528/2 "2016-06-03T18:53:59Z")

</div>

I haven’t had time to experiment with this yet. Do you have details on how it works? Does it poll requests, or maybe something more down to the metal TCP-ish?

---

<div class="post-metadata">

**Author:** ![kofno](https://metaruby.com/user_avatar/metaruby.com/kofno/32/159_2.png) [@kofno](https://metaruby.com/u/kofno)\
**Post date:** [June 3, 2016, 7:16pm UTC](https://metaruby.com/t/chat-rooms-on-rails-with-action-cable/528/3 "2016-06-03T19:16:31Z")

</div>

It uses websockets and rack’s “socket hijacking” feature. It then presents the concept of a channel, which allows you to broadcast messages bi-directionally between the server and the clients.

Threads are handled _inside_ ActionCable, so it can be run from any ruby server (Puma, Unicorn, etc), as long as that server can support socket hijacking (so not WEBrick).

EDIT: Oh yeah, I meant to include this link about socket hijacking → [Hijack by raggi · Pull Request #481 · rack/rack · GitHub](https://github.com/rack/rack/pull/481)
