New Features Introduced In Ruby 3.1 | Mindfire Solutions

Most of the developers have been working in rails 3.0.1, but the new version of rails (i.e. 3.1) is available now. I am going to discuss all the new features that I have found in rails 3.1 till now.

1. Auto bundle install

In rails 3.0.1, after creating the new application, we need to make bundle install manually.

e.g. rails new demo_app
This creates the required files and folders for the demo_app and after that we need to call “bundle install” for installing the gems.

But in new version while creating the application the bundle install runs automatically.

e.g rails new demo_app It will install the gems for the application by “bundle install” after creating the required files and folders for the demo_app.

2. Jquery is the default library in rails 3.1

In the Gemfile it include the gem ‘jquery-rails’ by default. That means we need not include the jquery.js in our application because it is already been there.
3. Introducing assets pipeline features

The main feature is introduced in the rails 3.1 is asset pipeline. In rails 3.0.1, we need to add the stylesheets, javascripts and images in the stylesheets, javascripts and images folder in the “application/public/” directory. But in this new version of rails, this feature has been moved to “application/app/assets/” directory. And these assets can be accessed directly to the application by using “assets/filename”

e.g. In rails 3.0.1, for background image in the stylesheet
.header{
background:url(/images/header.jpg) no-repeat center;
}
Here header.jpg is in application/public/images folder.
 
But in rails 3.1
 
.header{
background:url(/assets/header.jpg) no-repeat center;
}

Here header.jpg is in application/app/assets/images folder.

Apart from the above features, I have found a bug also. * While building an application in 3.1, I found the following issue while loading an initializer file on starting the rails server.

I have an storage.yml in the application/config folder. And this file will be loaded at the server startup. So I have created an intializer file (application/config/initializers/storage.rb) and put the following code.

yml = YAML.load_file(“#{RAILS_ROOT}/config/storage.yml”)

On server start up, it raised an error uninitialized constant RAILS_ROOT. It has been working perfectly in rails 3.0.1 but in the new version it shows the error. To fix it I need to change the code to following.

yml = YAML.load_file(File.expand_path(‘../../storage.yml’, __FILE__))

Now it should work in rails 3.1

150 150 Burnignorance | Where Minds Meet And Sparks Fly!