It was December 2015 when Ruby on Rails announced the first beta release of Rails 5.0, and yesterday, after four betas, two release candidates, and hundreds of contributors, Rails 5.0 is finally done.
One of the most important features of this release is Action Cable, a new framework that handles WebSockets in Rails. Action Cable is an integrated solution for managing connections, with two layers: one for server-side processing, and a JavaScript layer for client-side interaction.
(Related: Rails is popular with coding boot camps)
According to the Ruby on Rails team, Action Cable makes designing live features like chat, notifications and presence easier. For those developers who want to see a live use case, these features are currently a part of Basecamp 3, a private, secure collaborative space for developers.
The Rails team also added an ActionController::Renderer system, and Action Cable allows developers to access their entire Active Record and PORO domain model in their WebSockets work. Action Cable runs in-process with the rest of an app, and the team recommended running Action Cable servers in their own processes (which is how Basecamp runs at scale).
The other big feature of Rails 5.0 is the API mode. Rails is useful for the new crop of client-side JavaScript or native applications that need the back end to speak JSON, according to the team. Developers can see this in API mode.
“If you create a new Rails application using Rails’ new back end -api, you’ll get a slimmed-down skeleton and configuration that assumes you’ll be working with JSON, not HTML,” according to the team.
More work needs to be done for API mode, but for now, by default it relies on #to_json calls on model classes.
Other highlights of the release include:
- The test runner now reports failures inline, so developers don’t have to complete the suite to see what went wrong.
- ApplicationRecord has been born as a default parent class of all models created by the generators.
- No more accidentally halting Active Record callbacks because the last statement is false.