This page provides the simplest instructions for installing Ruby on Rails 3.0.x on a Windows PC. It closely follows the procedure in our text (Agile Web Dev with Rails, pp. 3 - 5), except it ensures that version 3.0.9 is installed.
Your first step is to install ruby, the language that Rails is built upon. A ruby installer is available for download at http://rubyinstaller.org/. Ruby 1.9.2-p290 is recommended. Download and run the installer. As you install, select the option "Add Ruby executables to your path." By default, ruby will be installed at C:\Ruby192 (the Ruby192 folder on the C drive).
You will need to use the Command Prompt for entering typed commands. The command prompt is accessed by clicking on the Windows "Start" icon at the bottom-left corner of the screen. From there, follow this navigation: All Programs --> Accessories --> Command Prompt. For easier access in the future, you may want to right-click Command Prompt to pin it to your task bar.
From the command prompt, you will want to learn how to navigate to various folders (sometimes called directories) on your computer. The command dir shows the files and folders in your current folder. You can switch to another folder by typing the cd (e.g. cd Documents). To go up to the parent folder type cd .. .
It is possible that you will need to update the gem installer that comes with ruby. The gem installer allows you to add new programs (e.g. Rails) that run on ruby. To test if you need to update the gem installer, type the following command at the Command Prompt:
gem -v
If the response has 1.3.6 or newer, you do not need to update the gem installer and you can skip to the next section.
To update the gem installer type the following commands at the Prompt:
gem update --system gem uninstall rubygems-update
We will use the sqlite3 database with Ruby on Rails. To get the necessary files, you will need to go to http://sqlite.org/download.html. Scroll down to precompiled binaries for windows and download the sqlite shell and the sqlite dll zip files. Copy the files in the zip folders to your C:\ruby192\bin folder. In this bin folder, you should then see dll and exe files for sqlite3.
We will be using Rails version 3.0.9 in this class and that is what you should install. Here are the commands for the Command Prompt:
gem install sqlite3 gem install rails --version 3.0.9
To really test if your installation is working, you should test it with a database. The easiest and most gratifying way is to create a scaffolded Rails application. Here's how to do that.
First, go to a directory where you will want to create your application directory. For example, if you want your application directory (folder) to be in the documents directory (folder), enter the following command:
cd Documents
Now create your rails application, giving it a name (e.g. travel):
rails new travel
I suggest giving your rails app name a thematic name like travel, music, dining, sports, etc, which should match the goals of your application.
Then change directory to your new applicaton:
cd travel
Create a scaffold:
rails generate scaffold Airport city:string code:string
Create the database table:
rake db:migrate
Start the server:
rails server
You can now verify if you application is working in a browser at http://localhost:3000/airports where the last word should be the plural version of your scaffold (model) name.