CALL US ⁄ ⁄   +61 3 9995 0765



If you are not that familiar with Ruby on Rails, it’s a web development framework that’s more than 10 years old now. Rails is a web application development framework written in the Ruby language. It is designed to make programming web applications easier by making assumptions about what every developer needs to get started. It allows you to write less code while accomplishing more than many other languages and frameworks. Experienced Rails developers also report that it makes web application development more fun. Today, Texo design - web app development services  will share somethings about Rails 5

Rails is opinionated software. It makes the assumption that there is a “best” way to do things, and it’s designed to encourage that way – and in some cases to discourage alternatives. If you learn “The Rails Way” you’ll probably discover a tremendous increase in productivity. If you persist in bringing old habits from other languages to your Rails development, and trying to use patterns you learned elsewhere, you may have a less happy experience.

Why You Should Be Excited About Rails 5?

After six months of polish, four betas, and two release candidates, Rails 5.0 is finally done! It’s the biggest release from the Ruby on Rails community since June 2013 and comes with an impressive range of features and changes.

It’s taken hundreds of contributors and thousands of commits to get here, but what a destination: Rails 5.0 is without a doubt the best, most complete version of Rails yet. It’s incredible that this community is still going so strong after so long.

The features of Rails 5.0 are as follows

1. Real-time data with Action Cable

+ ActionCable is a brand-new framework for handling WebSockets in Rails. It’s a completely integrated solution for managing connections, a channels layer for server-side processing, and a JavaScript layer for client-side interaction. It’s incredibly easy to use, and makes designing live features like chat, notifications, and presence so much easier.

+ ActionCable adds real-time features to Rails right out of the box. In the past, if you were thinking about which framework to use for a web app that relies on real-time features, then more often than not you’d be advised to use NodeJS and SocketIO or a comparable framework. This is because these frameworks enable you to add a variety of real-time features to your app such as chat messages or notifications.

+ Well, not anymore! ActionCable leverages Websockets to keep open connections between the user’s computer and the server. This way you can send data from your Rails server to all connected users and update whatever they see in their browser. The most obvious use case would be something like a chat app.

+ Want to learn more about it? Check out the official example app (it requires you to set it up locally). Basecamp, who make up the core team developing Rails, is the first and most popular web app using ActionCable for real-time communication among users.
2.  Rails API only application
Another big change is API mode. Traditionally, Rails is a framework for web apps that runs entirely in the web browser. It makes it very simple for you to build powerful and robust backend logic to interact with data and to integrate it with the frontend of your web app.

Nowadays, however, there are many use cases whereby the frontend and backend of an app are separated. Most commonly this would apply to smartphone or tablet apps. For example, you write your native app for Android or iOS but you want it to interact with a server to save data online. If this interaction is all you need your backend to do, you don’t need any HTML pages. You simply need a solid backend your mobile app can connect to. Basically you don’t need ActionController::Base, Asset Pipeline, Views, Helpers etc…

With Rails 5 you can generate your Rails app in API mode which means it will be generated without any of the things you would normally need if you were to run your Rails app directly in the browser. This includes, for example, the “views” and “assets” parts of Rails apps. You can then communicate with Rails through “RESTful” links and transfer data in simple JSON.

Command to create Rails API application:

rails new my_rails_api_app –api

If you want to Convert Existing Rails Application to API application

+ Open your config/application.rb file and add following line
config.api_only = true 

+ Edit your app/controllers/application_controller.rb

class ApplicationController < ActionController::Base


# change this inherit from ActionController::API

class ApplicationController < ActionController::API



3. Rake Inside Rails

For many a Rails noob, having to figure out when to use “rake” and when to use “rails” is a source of confusion. Now you don’t need to switch context between the “rake” and “rails” commands. You can run all Rake tasks with the “rails” keyword.

The source of this issue in previous versions of Rails is the fact that some commands make sense to be rails commands, such as “rails server”, and are not implemented as rake tasks, but the rest are implemented as rake tasks and are therefore called using “rake”. If you implement your own rake tasks, you would have had to also call them using “rake”.

In Rails 5, you can do everything with “rails” right now. For example, “rake db:migrate” is now “rails db:migrate”. This may not look like much on the surface, but this will make the lives of beginners much simpler. Rails 5 will also add a “restart” command that quickly restarts the application.
4. Rails 5 Only Support Ruby 2.2.2+
Rails 5 will only work with Ruby 2.2.2 or newer. In Ruby On Rails applications, we usually pass symbols all over the place, doing this open the possibility of DOS attacks when our memory is consumed by symbols that never get garbage collected.

Ruby 2.2.0 introduced changes in its garbage collector to be able to collect symbols.

Another reason for Rails 5 to support Ruby 2.2.2 is to take advantage of new Incremental GC which will help to reduce memory consumption by our Rails applications.
5. #or method in ActiveRecord::Relation
Finally ActiveRecord::Relation is getting #or method, this will allow us to write queries with ActiveRecord DSL as follows:

Book.where(‘author = 1’).or(Book.where(‘author = 3’)) 
\# => SELECT * FROM books WHERE (author = 1) OR (author = 3)

#or method accepts a second relation as a parameter that is combined with an or. #or can also accept a relation in a form of model scope.
6. #belongs_to is required by default
From now on every Rails application will have a new configuration option

config.active_record.belongs_to_required_by_default = true

It will trigger a validation error when trying to save a model where belongs_to associations are not present.  We can disable this validation on each belongs_to definition, just passing an additional option optional: true as follows:

class Book < ActiveRecord::Base 
   belongs_to :author, optional: true 

7.What else is new?
Rails 5 includes a whole number of big and small changes. Check out the full change log here to see everything that’s new. But just to give you an idea of some of the other things to look out for, here are a few more to keep in mind:

+ Rails has a new logo and welcome screen when you first create your app.

+ Rails uses Puma as the default web server now instead of Webrick (some articles online are outdated and suggest you  need a multi-threaded server such as Puma to run ActionCable. That used to be the case with early versions of ActionCable but that’s not necessary anymore. You can even use servers such as unicorn).

+ Turbolinks 5 promises to load your pages much faster than before.

+ Use built-in helper methods like “on_weekday” or “on_weekend” to check whether a date is a weekday or on a weekend.


Rails 5 is great news to both experienced and amateur programmers. It introduces some great new features such as ActionCable and API mode which offer us many more opportunities for building even more types of apps with Rails.

With Rails 5 you no longer have to make compromises, as you don’t even have to think about different frameworks if you’d like to have an API-only app or include real-time features. In a web where real-time data updates and speed are both increasingly important, the team behind Rails has made sure it’s a solid choice for modern app development for years to come.

Texo Design is one of the renowned names in ruby web design melbourne. We are the team of well – qualified and experienced staff as we deal with mobile apps, web development and social media campaign. We offer you the best tailor-made solution. Your success is our guarantee as we commit quality, professionalism and communication to our clients. These three pillars will help you in making your formal decision. We transform your ideas into reality with highly innovative technologies and experts mindset. Contact us +61 3 9995 0765 or for more information

Source Reference


Be the first to post on the blog

Leave a Reply


Back to blog