Getting started with rails on Ubuntu

Getting rails running on Ubuntu wasn’t as easy as I expected, there were a few bumps. This is what I learned in the process.

1. Ubuntu isn’t really keeping up to date with the ruby versions. If you do apt-get install ruby you will get version 1.8.7. I happend to get 1.8.7 p249 which turns out to be completely incompatible with rails3.

How to solve this: use rvm to manage ruby versions.
Follow the installation instructions.

2. You want to get ruby version 1.9.2. However it doesn’t come with openssl per default which you will need.

How to solve this: use rvm.

$ rvm package install openssl $ rvm install 1.9.2 --with-openssl-dir=$HOME/.rvm/usr  

3.  You want to install rails using gems.

How to solve this: go to rubygems Download, decompress and run setup.rb.

4. Now, you should be able to install rails. Don’t use sudo! This will mean that you override the rvm version of ruby and use your system version instead.

$ gem install rails

5. Time for sqlite3. But, you’ll probably get an error message unless you first apt-get install libsqlite3-dev. And then gem install sqlite3-ruby.

Ok, now you should hopefully be able to do a simple hello world. For example: