Rails 3.1 Stable Notes

Been working on Rails 3.1 apps. There is a good reason to use it even if there are existing issues.

All of my current projects (for clients and personal projects) have already been upgraded to Rails 3.1 RC4. This includes www.33voices.com.

Obviously, it works. I use both Rspec and Cucumber. If sufficient tests are written for your application, knowing what doesn’t work anymore isn’t a problem if you want to upgrade from 3.0.x or 2.x versions of Rails.

The good reasons are:

1) It’s an opportunity to clean up your code

In what ways? Check on your existing dependencies. Do you really need everything? Like asset packager? I know that the latest version of The Agile Web Development With Rails recommends that and it still works for 2.x and 3.0.x versions for Rails. But with Rails 3.1, you don’t need that because minifying stylesheets and javascripts is something supported by Rails 3.1.

2) It is more simple for newbies who want to learn HAML and SCSS or SASS

There is no need for commands like “sass –watch” and “compass watch.” Honestly I still don’t see the need for compass until now. If you’re fine without it and it doesn’t significantly improve your productivity, the conclusion is it is not necessary.

It is interesting that there’s a hackfest on July 23 or so. I’d be offline most of the day (traveling) but I hope to see what the Rails community is working on.

Create a gemset for edge Rails

This makes sense to me to avoid any conflict with apps using a lower version.

rvm gemset create edge
rvm use ruby-1.9.2-p180@edge
gem install bundler
cd appname
bundle install

How to test Rails 3.1 Stable

gem install rails --pre
rails new appname -d postgresql
cd appname

You must have postgreSQL installed via homebrew or so.

Edit Gemfile to use rails edge.

gem 'rails',     :git => 'git://github.com/rails/rails.git', :branch=>'3-1-stable'
gem 'sass-rails', :git=>"git://github.com/rails/sass-rails.git", :branch=>'3-1-stable'

Use Git Flow

It’s sensible to use it for all projects in my opinion. Read more about it here.

git flow init

More Configuration work

Edit .gitignore file and config/database.yml.

rake db:create:all 

That creates all databases though probably development & test environment would do. Encountered no issues so far.

rails server 

Gems you might need

We used to have them as helpers in Rails and now they removed it.

Rails auto_link (not official)

Prototype, Scriptaculous, and RJS for Rails 3.1

What is broken with Rails 3.1 Stable?

Cucumber-rails version 1.0.0 does not work with Rails 3.1 “stable” but works with Rails 3.1 RC4.

Precompiling assets doesn’t always work with naming conventions followed.

admin.css.scss.erb 

Why is it necessary to make it an erb file? You have to use asset_path to make sure the link to the static assets are correct.

Specify stylesheets to precompile. If you have admin.css.erb for example, that may be missed and won’t be precompiled.

config.assets.precompile += %w(admin.css.erb)

I have a few more notes about asset pipeline here.