Rails 3.1 release, rumors and news about features


What is the current status of  Ruby on Rails 3.1?

We all know that there isn’t a fixed roadmap/release date for Ruby on Rails 3.1, but there are definitely rumors about the new features and improvements. Yehuda Katz, a member of the Ruby on Rails core team, said “With 3.1 we’ll go back to basics and look at things that are less invasive internally, but could have a big impact on developers. If you want to check latest updates then click here and check milestones for Rails 3.1. It’s really a good news that just 26 tickets are remaining out of 68 total tickets.

Lets talk about new features which will be integrated with RoR 3.1.

Object Scopes in Rails 3.1

The change that is made to object scope is :

The above code describes that with Rails 3.1 it is possible to pass objects to scope methods that responds to the method ‘call’. Let’s understand what it means. Currently, with Rails 3 or Rails 3.0.x, scope works in the following way. For example, if we want to get all the products with name “Nokia” and with category “Mobile”, we used to create its scope method as given below.

Now to get required data, we use it like

But what if we have multiple classes that share the same logic for a named scope?? Suppose we want to get all the users with name = “John” and category = “Manager”. Think for a moment. In such cases it is obvious that we should be able to reuse same filter/scope code. Luckily, RoR 3.1 will provide exactly that kind of reusability. It will be possible to create classes that acts as scopes/filters.

In Rails 3.1, scope will be reused in other modules like this:

Its simply great !! Changing a simple is_a? to a respond_to? can unlock quite a power.

Automatic Flushing

The Rails 3.1 will have new feature named “Auto Flushing” which helps to boost the performance of Ruby on Rails application. Normally whenever we are downloading any page, there is a two step process: first, all the code gets compiled to generate html view and second, all necessary files like css, javascripts, images are being loaded one by one.

As you’ve probably seen, DHH announced that they try to add flushing in Rails 3.1 to improve the client-side performance of a typical Rails applications. The most obvious solution, and one that already exists in plugin form, is to allow a layout to have a new flush method, which would immediately flush the contents of the layout to the browser. By putting the flush method below the JavaScript and CSS includes, the browser could begin downloading and evaluating those static assets while the server continues building the page. For more information regarding this feature, you can check here .

Rails 3.1 > Integration of Spriting

One thing DHH mentioned in his keynote was that Rails 3.1 should improve the way Rails handles JavaScript, Style Sheets, icons and images. Rails 3.1 will support a technique called Sprite Generation which is basically a method for combining many graphics into a single image. That single image will be then displayed using CSS.

<% sprite_css(“icons”) %> this code does two things. First is to combine all the images within a single folder and second is to generating its CSS. The advantage of using such technique is to reduce dozens of HTTP requests into one cache-friendly image file.

Keep js/css close to the code in view folder

Guess what !! With Rails on Rails 3.1, we will be able to write the code for stylesheets and javascripts in the app/ * folder like this :

#This code will be compiled to the files like this:

The advantage of using the above feature is that after compilation of these files, your Ruby on Rails application will run on single CSS and javascript file which is neatly compressed without any kind of extra efforts.

What is going to be deprecated in Rails 3.1??

Passing options hash containing :conditions, :include, :joins, :limit, : offset, : order, :select, :readonly, :group, :having, :from, :lock etc inshort, finder methods which are provided by any ActiveRecord class will now be deprecated in Rails 3.1.

We used to write finder methods in this way

In RoR 3.1 it will be :

For more information you can check here.

From the above news about Rails 3.1 features, we can feel that Rails 3.1 will be another great release. Any guesses when we will see 3.1?

Author: Helmut M. Juskewycz

I like and create awesome Software! Besides developing, I am interested in a lot of things. Startups, Business, Gaming, Sports, Movies, just to name a view. Founder of LingoHub.

4 thoughts on “Rails 3.1 release, rumors and news about features

  1. I assume we cannot start using/testing these just yet by downloading edge?

Leave a Reply