Friday 05. of December 2008
Tags:rails 2.2, etags, entity tags, 118 gem     By: By: Sadaf Azad
Posted in Ruby

Finally, Rails 2.2 is released after the addition of multiple functionalities and features. Rails 2.2 contains a long list of improvements and newly added features and fixes. Significant new features include internationalizations and localizations, ETags support, thread safety and active records management. These features are briefly described below:

 Internationalization and Localization:

 I18 group has done a remarkable job of providing the “I18 gem” which is an easy to use and extensible framework for translating applications into a single custom language other than English, or to develop an application that has the ability to support multiple languages.

 The I18 gem of Rails allows the developers to customize the data according to their requirements. They can internationalize the data so that they do not have to type the same data again and again. They can also localize data by providing self defined translations and localized formats of the data that they want to modify. In other words, developers can customize and extend the I18 gem to write applications in their preferred languages. Developers can store the customized language files in a specialized format for later use.

 The I18 gem provides many functionalities, including:

  • Look up of translations by keys that can be both symbols and strings - arrays of symbols and strings can be used
  • Interpolate data into translations
  • Pluralize translations
  • Localize dates, numbers, currencies and more

 Clemens Kofler has demonstrated an example of localizing and internationalizing data in his demo application.

<h1><%=t  :hello_world %></h1>

 By affixing a ‘t’ before the symbol to be translated, the application will look for its translations in the already defined translation file. Here is a list of translations available as documented on the I18 website to help you localize the data. To localize an application in another language other than predefined translations, you must define a customized file according to your requirements and save it in “config\locales” (recommended).

 ETags (Entity Tags) Support:

HTTP ETags support is one of the major functionalities added to Rails 2.2. It allows Rails to send an empty response to an application in return of a ‘Get’ request, if the requested resource has not been modified lately. It acts to save resources in terms of bandwidth.  The ETag works in correspondence with the ‘last_modified’ operator to update the requested web pages.

 ETags are a great way to uniquely identify the contents sent by the web server. According to Amanda and Michael Morin,

Rails 2.2, adds specific support for ETags and checking the last modified date to help you save a little bandwidth.

It works like this: clients save the ETag when they request a page and, if they ever request the page again, they send the ETag along with it. The server can look at the ETag to determine if the content has changed since the client last requested it. If it hasn't changed, the server can send an empty HTTP body, saving quite a bit of bandwidth. For pages that users refresh often, such as the main page of a frequently visited Website, this can be a big bonus.”  

One can even consider using an existing plug-in  that has used the ETags feature of Rails 2.2 to get the functionality of checking HTTP cache.

 Thread safety

 Another feature rolled out in Rails 2.2 is thread safety. It allows the applications to have a reduced impact on memory, which means that multiple requests can be handled by the web server with small number of Rails copies in the memory.

There are two types of implementations that Rails core has to deal with:

  • In case of Green Threaded Implementations like Ruby, Ruby EE and Rubinius, a single instance of Rails can handle multiple requests at the same time but not concurrently as green threads never allow applications to run multiple threads concurrently.
  • In case of implementations like JRuby, a single instance of Rails 2.2 can handle multiple requests concurrently. Reducing the number of JRuby instances will also reduce the problem of a “cold start” and will allow the single instance running to warm up faster too. And, there would be no need to have multiple instances to run a given site as well.

 The overall impact of thread safety is memory utilization in an enhanced way and reduced memory usage.

 Connection Pool:

 In order to deal with the Active Records, the connection pool is a major feature added in Rails 2.2. The connection pool allows Rails to distribute the database requests across a pool of database connections. By default, the size of the database connections can grow to a maximum size of five but can be altered according to the requirements.

 Other features added in Rails 2.2 that make it distinct from the previous versions include better API, compatibility with Ruby 1.9 and JRuby and improved documentation. One of the good things about Rails 2.2 is that it has been tested and deployed on Mac OS X by many developers easily. Detailed information about the features added in Rails 2.2 can be accessed in the official released notes.

 

References

Charlie. “Re: Rails 2.2.” Online Posting. Oct 10, 2008. Rails retrived Nov 25, 2008. from “http://www.ruby-forum.com/topic/169172

“Headius” retrieved Nov 25, 2008 from http://blog.headius.com/2008/08/qa-what-thread-safe-rails-means.html

“Ruby on Rails 2.2 Release Notes” retrieved Nov 25, 2008 from http://guides.rubyonrails.org/2_2_release_notes.html

Amanda & Michael. “New in Rails 2.2: ETags” retrieved Nov 25, 2008 from http://ruby.about.com/b/2008/10/28/new-in-rails-22-etags.htm

You can leave a trackback from your own site.
Comments

Displaying results 1 to 5 out of 537
1 2 3 4 5 6 7 8 9 10 Next
 
   Ambien and memory loss. Tuesday, 07-09-10 06:45
Ambien memory. Ambien memory loss. Does ambien cause permanent memory loss. Memory loss from ambien.
   Cheap xanax. Tuesday, 07-09-10 04:18
Buy xanax. Buy xanax without prescription in usa.
   Ambien cr. Tuesday, 07-09-10 00:27
Ambien and pregnancy. Ambien prescriptions. Ambien next day delivery canada. Ambien side effects.
   Fioricet lt main lt twiki Monday, 06-09-10 22:37
Fioricet. Cheapest fioricet. Buy fioricet online without a prescription. Fioricet morphine.
   Ambien online. Sunday, 05-09-10 08:41
Ambien during pregnancy. Ambien awakening. Ambien. Ambien on line. Buy ambien online cod. Ambien cr.
1 2 3 4 5 6 7 8 9 10 Next
Sorry, comments are closed for this post.