Setting up Ubuntu Jaunty for Ruby and Rails development

Getting Ruby setup on Ubuntu – Jaunty

UPDATED: Added RSpec for Rails as well

Here are some quick steps to get you up and running with Ruby on Ubuntu, Take about 15 minutes depending on your internet connection.

Step 1: The first thing you need to do is update the packages in Ubuntu open the terminal window (Applications Menu | Accessories | Terminal) and type in the following commands.
   sudo aptitude update
   sudo aptitude dist-upgrade

Step 2: The next package will insure you have everything you need in order to build ruby packages on your system.
    sudo aptitude install build-essential

Step 3: Type in the following command to install Ruby NOTE: this is all ONE command

    sudo aptitude install ruby1.8-dev ruby1.8 ri1.8 rdoc1.8 irb1.8 libreadline-ruby1.8 libruby1.8 libopenssl-ruby

Step 4: Type in the following command to install SQLite3 NOTE: ONE command

    sudo aptitude install sqlite3 libsqlite3-ruby1.8

Step 5: Install Ruby Gems NOTE: Multiple commands
   tar xvzf rubygems-1.3.2.tgz
   cd rubygems-1.3.2
   sudo ruby setup.rb

!! You should get an error stating that Ruby command not found !!

Step 6: creating the ruby symlink (symlink stands for symbolic link, windows user can think of it like a shortcut)
   sudo ln -s /usr/bin/ruby1.8 /usr/local/bin/ruby

Step 7: Install ruby gems NOTE: you should be in the directory rubygems-1.3.2 when you run this command

    sudo ruby setup.rb

Step 8: We need to create the remaining symlinks for ruby utilities NOTE: Multiple commands

    sudo ln -s /usr/bin/gem1.8 /usr/local/bin/gem
    sudo ln -s /usr/bin/rdoc1.8 /usr/local/bin/rdoc
    sudo ln -s /usr/bin/ri1.8 /usr/local/bin/ri
    sudo ln -s /usr/bin/irb1.8 /usr/local/bin/irb

Installing Rails

Step 9: Install Rails

    sudo gem install rails –no-rdoc –no-ri

Step 10: Create a test project NOTE: Multiple commands

    cd ~
    mkdir apps
    cd apps
    mkdir rails_apps
    cd rails_apps
    rails testapp

Step 9: Start Webrick web server in your testapp directory


Step 11: Open up Firefox and navigate to http://localhost:3000, you should see a page with the text:
    Welcome aboard
    You’re riding Ruby on Rails!**

Step 12: Install Rspec
    gem install rspec

Installing source control

Step 13: Install subversion

    sudo aptitude install subversion

Step 14: Install Git because you are going to use plugins from GitHub

    sudo aptitude install git-core

Step 15: Install Git-svn

    sudo aptitude install git-svn

Step 16: Add SVN Like Shortcuts to Git

    git config –global status
    git config –global commit
    git config –global checkout
    git config –global branch

Step 17: configure the global user for Git
    git config –global “Put your full name here”
    git config –global [email protected]

Step 18: colorize the output for Git
    git config –global color.branch auto
    git config –global color.diff auto
    git config –global color.interactive auto
    git config –global color.status auto


Installing RSpec for Rails

I want to put a disclaimer here that this is my preferred way of installing RSpec from GitHub. It is not the only way.

Step 19: Navigate to the root of your Rails project. I am assuming that in this case it will be “testapp”

Step 20: Install Rspec for Rails from GitHub as Git submodules. NOTE: Multiple commands

git submodule add git:// vendor/plugins/rspec

git submodule add git:// vendor/plugins/rspec-rails

Step 21: Run the rspec generators, this will enable the rspec_* controller, scaffold, model generators

ruby script/generate rspec

This is going to drive you nuts if you have to remember to do this for every rails project you create so I created a simple bash script.  Actually the contains more than the bash script it also has the aliases that I use for Rails development.

Step 22: Navigate to your home diretory

cd ~

Step 23: Create the .rails_aliases file

gedit .rails_aliases

Step 24: In gedit copy the following text to the .rails_aliases file

alias ror-doc-spec=’open -a Firefox doc/plugins/rspec-rails/index.html’
alias ror-doc=’open -a Firefox’
alias ror-scaffold=’ruby script/generate rspec_scaffold’
alias ror-controller=’ruby script/generate rspec_controller’
alias ror-model=’ruby script/generate rspec_model’
alias ror-git-customerror=’script/plugin install git://’
alias ror-console=’ruby script/console’
alias rapps=’cd ~/apps/rails_apps’
alias ror-serv=’ruby script/server’
alias ror-logtail=’tail -f log/development.log’</p>

# Configures a rails app to use rspec
        git submodule add git:// vendor/plugins/rspec
        git submodule add git:// vendor/plugins/rspec-rails
        ruby script/generate rspec

Step 25: Save the file and close gedit

Step 26: Open your .bashrc file from the terminal window

gedit .bashrc

Step 27: Add the reference to your .rails_aliases file in your .bashrc at the top of the file add the following line:

source ~/.rails_aliases

Step 28: Save the file and exit gedit

Now if you want to add RSpec to any rails project you simply navigate to the root of a rails project and type:


If you want to add a controller with RSpec specs you simply have to type:

ror-controller BlogPost title:string author:string content:text …

Hope this helps! Happy coding!

Role Storming