Rails 5.0.0rc1 Released – Is ActionCable Ready for Prime Time?

This is the first post from the engineering team at ClearVoice. We'll be writing about the technology we use to build ClearVoice, the future of the platform and other related topics.

As the web evolves and users become more demanding, the need for web applications to be interactive and immediate grows. The engineering team at ClearVoice has been working hard to add interactive features to the ClearVoice platform to take advantage of the latest browser technology. Last month we released a major update that includes realtime messaging, presence and collaborative editing.

Before starting development of the realtime features we explored several options. We looked at building a home-grown solution with socket.io, we tested hosted services such as Pusher and PubNub, and finally we evaluated the beta of ActionCable the new realtime system built into Rails 5. At the time, ActionCable had no clear release date. Ultimately we ended up going with Pusher to solve our needs. This decision came down to the ease of implementation, cost, reliability and popularity in the community. We were not able to select ActionCable not only because it was still in beta, but also due to the lack of fallback support in the case of failed WebSocket connections. Both Pusher and PubNub have several layers of graceful fallbacks in their client implementations. They both provide fallbacks if the browser does not have native WebSocket support and will also fallback to HTTP longpolling in the case that a firewall or other network device prevents WebSockets from functioning correctly.

Although we did not select it at the time, I feel that ActionCable has a lot of potential. It makes building realtime apps with Rails incredibly straightforward. I recently gave a talk at the local Ruby::AZ Meetup group about ActionCable, including live-coding a chat system with user registrations and authentication.

Rails 5.0.0rc1

Here’s a quick peek at getting a very basic ActionCable example wired up:

First off, we need to make sure we have Ruby 2.2.2+ installed. I’m not going to include ruby install instructions here, but I recommend using rbenv, which can be easily installed via brew on Mac OSX.

As a prerequisite, check to ensure you’ve got Ruby 2.2.2+ and install rails 5.0.0rc1:

1. Create our app (the _5.0.0rc1_ tells the rails shim that we wish to use rails 5.0.0rc1), initialize a git repository and make our first commit just in case we need to revert anything we do:

2. Create a rooms controller, a message model, run the migrations to create our messages database table, commit and create a test message:

3. Okay, we’ve got the basic plumbing for a rails app with a rooms controller and a message model. Lets point the root route of the app to rooms#show. Open up config/routes.rb and replace “get ‘rooms/show'” with “root to:’rooms#show’:

4. Now it is time to fire up the app and see what we have:

Open up in the browser at http://localhost:3000 and:

5. Success! Our controller is loading. Now let’s display our messages in the room – populate the following files:

ActionCable Chat


<%= render @messages %>


<%= message.content %>


Lets commit these changes: $ git add . $ git commit -am “Add rooms/message views”

Now open up http://localhost:3000 again and see what we’ve got:

What we have here is a basic rails app with our test message rendered. This is Rails 101. Just about the simplest possible app. With ActionCable it’s just as simple to add realtime functionality, so lets do it:

6. Generate a ActionCable channel with a ‘speak’ action:

7. Implement the received and speak in app/assets/javascripts/channels/room.coffee:


” speak: (message) -> @perform ‘speak’, message: message

8. Update the channel subscription and implement ‘speak’ in app/channels/room_channel.rb:

And lets commit:

Restart the rails server process and test in two windows at http://localhost:3000:

To see a complete chat app built including user registrations and authentication check out the video I recently made after giving a talk on the subject:

What has your experience been with the realtime web? If you’re a developer, have you checked out ActionCable? Let us know your thoughts on social media using #ClearVoice or take it to the comments on HackerNews


Category: ClearVoice

About Jeff

Jeff Nappi is the Director of Software Engineering at ClearVoice. Follow him on Twitter.

Build Your Content Team

Get instant access to talented writers

Try the marketplace
  • neuronsong

    Great demo of rails5 and actioncable. Just a few typos, however. “speak(message): ->” needs to be “speak: (message) ->”. Also, “{data}” needs to be “#{data}”.

    • JeffNappi

      Fixed, Thanks!

  • Matheus De Sousa Bernardo

    I don`t know anything about websockets. where can I learn more?

    • JeffNappi

      There’s a ton of resources out there. Essentially WebSockets let your browser connect directly to your application to send and receive data in real-time. The Wikipedia article has a great explanation: https://en.wikipedia.org/wiki/WebSocket, what else would you like to know?

      • Matheus De Sousa Bernardo

        My problem is that I did not understand the point 7 and what a channel is. But im going to look on the wikipedia article first. Also I need to study TCP and HTTP Im on college but I did not take yet a network class.

        • JeffNappi

          Channels in this context are ActionCable’s abstraction on top of WebSockets that allow you to have multiple event streams processed independently. A Networking class would not be necessary to get familiar with this. Channels are a common abstraction used by realtime services such as Pusher, PubNub. They are also widely used in other open-source platforms such as Phoenix, Django, Socket.IO, etc. More importantly – just follow my instructions or check out my video and the git repository where you can play around with the solution.

          If you are learning I recommend just jumping in and building things and putting together the deeper knowledge after you’ve seen it work.

  • El nino

    The prerequisite for installation should be >= 2.2.2 and not 2.2.+, that was the error i got earlier, though its pretty straight forward to upgrade “activesupport requires Ruby version >= 2.2.2”

    • JeffNappi

      Fixed, Thanks for the catch! 🙂

  • Kegan

    Around the 17:00 mark, I do not have any input showing up on my app.


    From the terminal:

    Started GET “/cable/” [WebSocket] for ::1 at 2016-05-23 16:19:53 -0600

    Successfully upgraded to WebSocket (REQUEST_METHOD: GET, HTTP_CONNECTION: Upgrade, HTTP_UPGRADE: websocket)

    RoomChannel is transmitting the subscription confirmation

    RoomChannel is streaming from room_channel

    RoomChannel#speak({“message”=>”Travis: Neat!”})

    [ActionCable] Broadcasting to room_channel: “Travis: Neat!”

    RoomChannel transmitting “Travis: Neat!” (via streamed from room_channel)


    From the web-console:

    App.room.speak(‘Travis: Neat!’)



    But no messages come up except for the “hello world” which was already there. I have gone back through and checked the code… it should be working, but somewhere ActionCable is not. Any ideas where/what to check for? Thanks in advance!