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.
Rails 3.1 > Integration of Spriting
<% 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
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?