You are currently viewing New Features and Major Changes in Rails 5
vteams- blog

New Features and Major Changes in Rails 5

  • Post published:January 21, 2016


ActionCable is a library that will ship with Ruby on Rails 5. It integrates WebSockets with the rest of your Rails application that facilitates you to push live updates to your client. This will make it easy to add real-time features to a Ruby on Rails application.

This library runs in a separate process from the main application server and needs a multi-threaded web server like Puma or Thin. Therefore, Puma is added as a default web server in Ruby on Rails 5.


In earlier versions of Ruby on Rails, all models were inherited from ActiveRecord::Base. But now starting from Ruby on Rails 5, all models will be inherited from ApplicationRecord. Its class will be used for customization and extensions needed for an application, instead of monkeypatching ActiveRecord::Base.

By monkeypatching ActiveRecord::Base, the extra functionality is added to all models. On the other hand, if you want to include an extra functionality to ApplicationRecord then it will be localized to the models inheriting from ApplicationRecord.

Rails API

Rails 5 allows you to generate API-only applications. The rails-api gem has been merged to rails gem that allows you to generate API-only application and strip out all extra middleware.


Rails 5 have introduced another very useful feature for generating a random token. If you need a random token in your model, you can use ActiveRecord::Base#has_secure_token which handles this process.

Attributes API

Your models will get a new attribute class method in Rails 5 that allows you to easily define a relationship between the model and a non-Active Record type. No more misusing is serialized!


With Rails 5, ActiveRecord::Base#where.or has been introduced. You can now perform SQL “or” operation with Rails way as:

Post.where('id = 1').or(Post.where('id = 2'))