Wednesday 26 November 2014

What has changed in ROR 4.2 - The new version of Rails

ror development
During mid-August the ROR 4.2 was announced for the first time. Now when it is out it definitely looks to go a long way. Besides being the latest and upgraded version, this time certain interesting changes have been introduced in the Ruby on Rails application. Moreover, since it is the recent version it is being widely applied to solve performance issues across the various ROR versions.

Let’s explore the changes one by one:

Active Job and Action Mailer
Delayed Job, Resque, Sidekiq, etc are queuing systems and on top of these lies Active job, an adapter layer. This feature can be used to note down the jobs and they will be running on the queues without any changes. This happens due to the pre configured inline runner. It is a new framework that has been added to Rails 4.2.

Besides the Active Job, there is Active Mailer that is available with #deliver_later method which can add an email that is to be used to the queue. If this is done the model or controller cannot be bogged down at all.

Adequate Record
This version of ROR is also packed with another performance improving feature, known as Adequate Record. This is a set of patches that enables the Active Record to be faster twice. As far as Active Record is concerned it transforms the relation objects to ARel ones. The ARel objects stand for the SQL query AST. Lastly, the Adequate Record can also convert the AST to a real SQL string that is further made to pass to the database.

The Adequate Record works by caching onto the SQL query pattern even when it executes the Active Record calls. The cache, thus, helps in skipping some part of the computation that is engaged in transforming the calls into SQL queries.

Web Console
This is a set of debugging tools used for the ROR application. In a default Rails error page the interactive console is automatically launched. Inspecting the stack trace as well as executing the Ruby code becomes easy with this. Thus running the rail console proves to be quite handy. At times, however, it is not easy to access or share the session with a friend if it is configured with a remote desktop server. It is in this regard that the web console can help the rails console to run. These are found on the in the terminal right in the browser.

Support for Foreign Key
Initially there was no support for the foreign key – neither while adding it nor while removing it. But this time it is different. These keys are immensely useful to ensure that the data stays consistently and corrected even while the records are removed. This feature is supported ROR out of the box.

Bootstrapping apps
For enabling an automated setup code while bootstrapping an app, a new feature has been launched, known as setup or bin. If you have already written down the script then it is time to rename it. For almost all the Rail applications, you need to run certain commands before they are tried out. Even if the apps are almost empty they would require the database to be setup prior to the booting. This is also the place where you should include other codes required to run your applications as well.

HTML Sanitizer
Finally, ROR has replaced the HTML Sanitizer with a more robust framework that has been built across Nokogiri and Loofah. The advantages of this new sanitizer are that it has been built more powerfully and it is also more secure.

Besides the mentioned changes there are other several changes as well, like, the following:
  • JSONB datatype is supported by PostgreSQL adapter
  • ActiveRecord::Base#validate! has been introduced. This leads to the display of RecordInvalid if the record is actually invalid.
  • In order to define the validation on the association a :required has been added to the singular associations.
  • #valid? Has found a new alias in #validate
Owing to such changes and more, the ROR 4.2 is being considered as an application that will help I further improvements. You can get in touch with a Ruby on Rails development company, who can help you develop web apps that are stable, scalable and secure.

We provide ror development services. If you would like to hire Certified Rails Programmers for your development needs, please contact us at Mindfire Soltuions.