Really silly percentage calculation in Ruby

22 03 2009

Content moved to


Upgrade to Rails 2.2 on Windows

17 01 2009

A glimpse at the bottom of the Rails 2.2 release notes show that Rails 2.2 require RubyGems version 1.3.1.

After failing to simply gem update –system, try the following:

> gem install rubygems-update
> cd c:\ruby\lib\ruby\gems\1.8\gems\rubygems-update-1.3.1
> ruby install.rb

This will successfully update RubyGems, and you should finally be at:

> gem -v

Now, we can simply do

> gem install rails
Successfully installed activesupport-2.2.2
Successfully installed activerecord-2.2.2
Successfully installed actionpack-2.2.2
Successfully installed actionmailer-2.2.2
Successfully installed activeresource-2.2.2
Successfully installed rails-2.2.2
6 gems installed
Installing ri documentation for activesupport-2.2.2...
Installing ri documentation for activerecord-2.2.2...
Installing ri documentation for actionpack-2.2.2...
Installing ri documentation for actionmailer-2.2.2...
Installing ri documentation for activeresource-2.2.2...
Installing RDoc documentation for activesupport-2.2.2...
Installing RDoc documentation for activerecord-2.2.2...
Installing RDoc documentation for actionpack-2.2.2...
Installing RDoc documentation for actionmailer-2.2.2...
Installing RDoc documentation for activeresource-2.2.2...

So far so good. Now, if you froze an earlier rails version in your app, setting it free is as simple as:

rake rails:unfreeze

At this point, update your config/environment.rb to rails version 2.2.2, and then run:

>rake rails:freeze:gems
(in C:/code/app)
Freezing to the gems for Rails 2.2.2
rm -rf vendor/rails
mkdir -p vendor/rails
cd vendor/rails
Unpacked gem: 'C:/code/app/vendor/rails/activesupport-2.2.2'
mv activesupport-2.2.2 activesupport
Unpacked gem: 'C:/code/app/vendor/rails/activerecord-2.2.2'
mv activerecord-2.2.2 activerecord
Unpacked gem: 'C:/code/app/vendor/rails/actionpack-2.2.2'
mv actionpack-2.2.2 actionpack
Unpacked gem: 'C:/code/app/vendor/rails/actionmailer-2.2.2'
mv actionmailer-2.2.2 actionmailer
Unpacked gem: 'C:/code/app/vendor/rails/activeresource-2.2.2'
mv activeresource-2.2.2 activeresource
Unpacked gem: 'C:/code/app/vendor/rails/rails-2.2.2'
cd -

Now run your tests suite. You do have tests. You do.

Bonus: If you are stuck on windows, do yourself a favor and use console2 for a half decent command prompt. Easier to select/paiste text, resize the window (no full screen (!!!)), tabs, and other goodies.