Episode 2 - The Best Windows Ruby on Rails Setup, Part 2
Episode 2 – The Best Windows Ruby on Rails Setup, Part 2

This is the second part to getting a Windows machine set up for Ruby on Rails Development by having Ubuntu running inside Virtualbox. View Part 1 here. Today’s screencast will walk through installing Ruby, rubygems 1.3.5 and Rails with rubygems, and SqLite3 as well as installing my preferred code editor Komodo Edit. Watch the screencast or read below for the written instructions.

Edit

This same procedure has now been tested on Ubuntu 9.10 and works fine.

[podcast format=”video”]http://blip.tv/file/get/Curtismchale-TheBestRubyOnRailsSetupForWindowsPart2281.mov[/podcast]

View Part 1

Installing Ruby

To install Ruby in Ubuntu we can simply install from the built in repository in Ubuntu. You don’t need to compile this from source if you don’t want to.

[bash]sudo apt-get install ruby-full build-essential[/bash]

Now let’s see what version of Ruby we have.

[bash]ruby -v[/bash]

This should return something along the lines of:

[bash]ruby 1.8.7p5000 (2009-02-22) [i686-linux][/bash]

And finally let’s check to make sure the Ruby library is working.

[bash]ruby -ropenssl -rzlib -rreadline -e ‘puts :Hello'[/bash]

Should return

[bash]Hello[/bash]

Installing Ruby Gems

Ruby Gems should be compiled from source using the latest version of Ruby Gems. The first line of bash I run just runs two commands one after the other.

[bash]
mkdir src
cd src
wget http://rubyforge.org/frs/download.php/57643/rubygems-1.3.4.tgz
tar -xzvf rubygems-1.3.4.tgz
cd rubygems-1.3.4
sudo ruby setup.rb
sudo ln -s /usr/bin/gem1.8 /usr/bin/gem
[/bash]

Nothing shows as output form the last command. It creates a symbolic link.

Installing Rails

Now that we have Ruby Gems installed Rails is a very simple thing to install. You should think of Rails to Ruby as you think of jQuery to Javascript. Rails is simply a set of assumptions about how you want to use Ruby that is bundled into a Gem. Install Rails through Ruby Gems with a single line.

[bash]sudo gem install rails[/bash]

Testing Your Rails Installation

Now that we have Ruby on Rails installed properly we should test it just to be sure.

[bash]
cd ~/
mkdir sandbox
cd sandbox
rails test-app
cd test-app
script/server
[/bash]

Now open up Firefox and enter “localhost:3000” into your url bar. You should see the standard Ruby on Rails starting app page.

Edit

As you’ll notice in the screencast Rails works but gives a warning and I wasn’t sure what it was. Thanks to Brian Mayle who helpfully points out the answer in the comments. We still need to install the sqlite3 connector. So run the following two lines and you’ll be right as rain.

[bash]
sudo apt-get install libsqlite3-dev
sudo gem install sqlite3-ruby
[/bash]

Installing Komodo

Finally we’re going to install Komodo Edit which is my preferred code editor for Ruby on Rails projects. I have tried Bluefish, Netbeans and many other but just keep coming back to Komodo Edit as superior for how I work.

Start by downloading Komodo Edit and just directly opening it in the Archive Manager. Drag the resulting folder onto your desktop and jump back into the terminal and run the commands below.

[bash]
cd ~/Desktop/Komodo-Edit-5.2.0-4075-linux-libcpp6-x86
sh install.sh
[/bash]

Now it’s going to ask where you want to install your software. I like to keep things organized so I install all of the custom apps inside my Home folder in a folder called software. Run the following commands to accomplish this.

[bash]
/home/myuser/software/Komodo-Edit-5
[/bash]

Next we have to insert the executable in our PATH variable with the command below.

[bash]
sudo ln -s ‘/home/myuser/Software/Komodo-Edit-5/bin/komodo’ /usr/local/bin/komodo
[/bash]

Now you’ll have a new ‘icon’ on your desktop that says ‘komodo-edit-5.desktop. This is the actual icon to launch the application but first we need to right click on it select ‘Properties/Permission” and check the box that allows executing as a program. You should now see the proper Komodo Edit Icon.

I like to drag this icon into the software folder we created and then from there drag it into the top bar in my Ubuntu installation so I can launch the application easily.

Conclusion

Now we have a working Ruby on Rails development environment with a working code editor. If you have any questions let me know in the comments.

Links used

6 responses to “The Best Windows Ruby on Rails Setup Part 2”

  1. Thu Avatar
    Thu

    You need to install rake by
    sudo gem install rake

    1. Curtis McHale Avatar

      Ah is that why I was getting the error in rails? I still haven’t had a chance to head back to it and sort the issue.

  2. Brian Mayle Avatar
    Brian Mayle

    rake is already installed when you install ruby

    sudo gem install rails
    Successfully installed rake-0.8.7
    Successfully installed activesupport-2.3.4
    Successfully installed activerecord-2.3.4
    Successfully installed rack-1.0.0
    Successfully installed actionpack-2.3.4
    Successfully installed actionmailer-2.3.4
    Successfully installed activeresource-2.3.4
    Successfully installed rails-2.3.4
    8 gems installed
    Installing ri documentation for rake-0.8.7…
    Installing ri documentation for activesupport-2.3.4…
    Installing ri documentation for activerecord-2.3.4…
    Installing ri documentation for rack-1.0.0…
    Installing ri documentation for actionpack-2.3.4…
    Installing ri documentation for actionmailer-2.3.4…
    Installing ri documentation for activeresource-2.3.4…
    Installing ri documentation for rails-2.3.4…
    Installing RDoc documentation for rake-0.8.7…
    Installing RDoc documentation for activesupport-2.3.4…
    Installing RDoc documentation for activerecord-2.3.4…
    Installing RDoc documentation for rack-1.0.0…
    Installing RDoc documentation for actionpack-2.3.4…
    Installing RDoc documentation for actionmailer-2.3.4…
    Installing RDoc documentation for activeresource-2.3.4…
    Installing RDoc documentation for rails-2.3.4…

    There error comes from sqlite3. To fix it you need to install the sqlite3 connector:

    sudo apt-get install libsqlite3-dev
    sudo gem install sqlite3-ruby

    1. Curtis McHale Avatar

      Yeah I was talking through it with another friend and that’s what we came up with as the likely problem as well. Thanks for writing it down for us all though.

      Have a good one.

  3. Max Avatar

    Thanks for posting the video. It is very easy to understand. Make sure to check out Part 1 of this tutorial before reading the second one.

    1. Curtis McHale Avatar

      I’m glad you found the video useful.