This is a really simple chatting app to demonstrate one implementation of Action Cable in a Rails 5 app. Users can sign up/log in with a username and create a chatroom or choose from an existing one to start real-time messaging.
This app builds on an earlier application, built out through this blog post on the Heroku blog.
This application, however, implements a slightly different approach. On the master branch you'll find an Action Cable implementation that follow's DHH's pattern from this screencast. Instead of interacting with the Messages Controller, we handle all of our message creation, broadcasting and streaming from the Messages Channel. Active Job + the new Rails 5 Action Controller render anywhere feature helps to make this happen.
On the multiple-rooms branch, we dynamically create a subscription for each existing chatroom, and our Messages Channel broadcasts to/streams up each specific subscription.
To learn more about the multi-room approach, check out this blog post. You can follow along with the blog post by forking and cloning this lab, and checking out the starting-state branch.
You'll need:
- Ruby 2.3.1
- Rails 5
- Postgres
- Redis
Then, once you clone down this repo:
bundle install
rake db:create; rake db:migrate
And you're all set.