Rails 5, is there something new? (part 1)

Two and a half years ago was the time when the latest major Rails was released. During this period A LOT of things changed on the daily basis of a Web Developer. After so long time this new release is expected with anxiety and brings an opportunity to find answers about the Rails future.

At Vizir we are already using the Rails 5 beta, so it’s a good opportunity to share our impressions and thoughts about what is new in this major version.

Up front there are two changes and one new thing, that were the main reasons for us to choose Rails 5, even in beta, to be part of the project stack.

Action Cable — the new guy

The rising of even more interactive interfaces was one of the big changes in the last two years. What was before something very hard to achieve (just remember Gmail in 2007), now it’s almost a commodity.

Part of this facility is due the use of WebSockets, that came along with HTML 5 and it achieved popularity with Socket.io.

Trello, Slack, Pusher and so many others are examples of services that have been using WebSockets to bring great features to their products. And now with Action Cable, Rails apps can easily use WebSockets to build live/real-time features.

To make this happen Action Cable uses a mix of tools:

  • Redis: is used to store the messages (the first version is very coupled with Redis, but there is an intention to decouple and use others pub/sub tools);
  • websocket-driver-ruby: to make the WebSockets communication, it’s almost a copy and past from the gem created by James Coglan, from Faye;
  • concurrent-ruby: to work with Thread Pools;

Beyond that to bring all the abstraction, well know as the Rails magic, Action Cable presents us two frameworks: one JavaScript to be used in the views, and another in the server-side to enable your server to “speak” WebSocket. With that you don’t need to go deep in the tools cited above to start making awesome features with WebSockets in your Rails apps.

In conclusion…

Looking inside Action Cable we noticed that a great effort was made to enable the use of WebSockets, directly from our Rails app. After all, good part of the tools that made WebSockets possible in Rails, are well known by the Rails community (even EventMachine was used before the beta version, but it lost his place to the websocket-driver-ruby)

Action Cable is clearly a new feature to keep Rails relevant in today’s web scenario, what is very welcome and show a signal that the core-team is aware of the new demands.

What we saw in this beta, showed to us there are a lot of space to improve, what is natural from something in its first version. The highlight is really bring the possibility to use WebSockets inside your Rails app. Decreasing the complexity of your application, when compared with the effort to integrate Rails with others tools that allow WebSockets “conversation”, and with new concepts (like channels, that will be covered in a new article), Action Cable tries to simplify the WebSockets implementation for developers that are getting started with live/real-time features.


In the next article, we are going to talk about the other two reasons that made we choose Rails 5: the improvement on performance and the Rails API.

And if you got interested to know more about Action Cable and see how to use it, we are going to write a tutorial that will show how to use Action Cable with vanilla JavaScript and Angular.JS. See you soon! :)

Like what you read? Give Fabrício a round of applause.

From a quick cheer to a standing ovation, clap to show how much you enjoyed this story.