Ruby On Rails 4.2 Features

Ruby on Rails 4.2 Features that Enhances its Performance

Ruby on Rails or ROR as it is popularly called is now the go-to choice for companies and startups requiring the deployment of a business specific application on various mobile platforms with maximum benefits in the least amount of development time frame.

Since it is open source and written in Ruby, it is a brilliant choice for web app developers to develop feature-rich content within a budgeted framework. Ruby on Rails is the best choice for makings apps for web especially since it is a brilliant alternative to erstwhile programming languages due to its simplicity and the ergonomically designed environment to put programming at the fore.

Details

  • The framework is enterprise-ready and because it is open-source, it is a brilliant choice for developers who run startup app development firms.
  • Since its inception, it has witnessed many bug-fixes and framework enhancements. The latest release is version 4.2 which was released in December 2014.
  • A slew of new and updated features are a part of this update which include Web Console, Active Job, Foreign Key support, Adequate Record that developers can include in their own apps.

If you are planning to upgrade your current ROR installation, read further to know more about these new features:

1) Active Job and Action Mailer – #deliver_later

Active Job is a smart new adapter layer which works on top of various command queuing systems like Sidekiq, Resque, Delayed Job, etc. With this feature, you can now write your various jobs directly to Active Job and the queuing systems will run on these queues with no specific changes.

The updated Action Mailer now has a new a ‘#deliver_later’ method, which enables you to add your email ID to be sent as a specific job to a queue.

The ‘#deliver_later’ method smartly enqueues the specific email to be delivered through the CMS with Active Job which sends the email using the deliver_now code when the job is run.

The GlobalID library also makes it easy for such commands to pass the Active Record objects to end-jobs by helping to serialize them in a valid and generic form which means that you won’t have to pack or unpack your Active Records each time for passing ids.

All you have to do is to give the job to the Active Record object which will serialize it with GlobalID and deserialized during run time. Attachments can also be added while the email template is being rendered.

2) Adequate Record

The Adequate Record is an updated set of patches and fixes for Active Record which now makes Active Record’s execution two times faster during job execution. Normally, ActiveRecord helps to construct an SQL string after making multiple transformations to it.

In order to process faster, the AdequateRecord function allows any static data to be separated from dynamic data directly to cache the static data processing.

What this helps in doing is that when Active Record makes a transformation while processing relation objects, it turns the specific relation objects into ARel objects which correlate to SQL query AST. It helps to convert any AST to an SQL string which passes it on to a database.

3) Web Console

Web Console is a highly specialized set of debugging tools for your Rails installation. Whenever rails encounter an error an interactive console is launched in the Rails error page to help you quickly inspect any stack trace and to execute the Ruby developed code within the stack trace binding.

This console works really well since it helps to share your current session with a co-developer without having to configure a new remote desktop. You can run a ‘rails console’ in a terminal right inside your browser with the help of a command line interface.

4) Foreign Key Support

The migration DSL now has the brilliant support of adding and removing any foreign keys. They are easily dumped to theschema.rb for quick removal. Currently post gresql adapters, MySQL and mysql2 have support for foreign keys.

There is also now a direct “connection#supports_foreign_keys?” method which determines whether the adapter you are using supports the API you have selected or not.

5) HTML Sanitizer

The previously buggy HTML sanitizer has now been replaced with a more robust version which is built on Nokogiri and Loofah which makes it more secure and its HTML code sanitization a little more flexible.

The new algorithm now makes the sanitized output a little different from older pathological inputs. If you still need exact output according to the older sanitizer, you can easily add the “rails-deprecated sanitizer gem” to the Gemfile which will make it run on the old behavior pattern.

Undoubtedly, these new and updated features will make Ruby on Rails more user friendly and robust during development. This is a critical step since ROR version 5 is also under development and it is taking cues from the performance of this version. Try them and experience the sheer power of web app development with Ruby on Rails!