To have control over your development environment when creating Ruby on Rails applications it’s best to use your own computer. It’s not a one-click install, so many tutorials recommend using cloud based service like Cloud9. But to remove all possible costs and to give you some knowledge at the same time these instructions will have you set up and a basic web application running in no time.

(The instructions that follow have been run on a Windows 7 machine that did not have a ruby installation.)

Install Ruby

The easiest way to install Ruby is by downloading the self-contained installer that you can find at RubyInstaller.
Ruby Installer Website

Click on the big red “Download” button. This will show you a long list of download options. It’s recommended that you choose the latest Ruby version.

Ruby Installer Download Page

Once the executable installer file has downloaded, run it. On the “Installation Destination and Optional Tasks” window select all 3 checkboxes:

  • Install Td/Tk support
  • Add Ruby executables to your PATH
  • Associate .rb and rbw files with this Ruby installation

Ruby Installer Destination Window

Install Ruby Development Kit

The Ruby Development kit is useful on Windows machine to easily use native RubyGems that require Unix tools like make, gcc and sh.

It is on the Ruby Installer Downloads page on the left under the heading DEVELOPMENT KIT.
Ruby Development Kit Download page

Choose the development kit that relates to your Ruby version. This is a self extracting archive so extract the files somewhere on your hard drive. Then run these commands from a command prompt to install the development kit:

cd <Ruby Development Kit directory>
ruby dk.rb init
ruby dk.rb install

The output should look something like:
Ruby Development Kit Installation

Install RubyGems

RubyGems are used to distribute programs and libraries (or gems) used by Ruby.

Download the TGZ file from RubyGems download page.

RubyGems Download page

Extract the contents of this file, and add RubyGem’s bin directory to your System Path. For instructions on how to do this see this page.

Ruby Gems Exttraction

Install SQLite3 Database

SQLite3 is an open source, free, cross platform database that will be used to test the Ruby on Rails blog application

Download SQLLite Tools from the download page, under the “Precompiled Binaries for Windows” heading. The tools version includes some useful command-line tools that you may find useful down the track.

SQLite Download Page

Extract the contents of this file and and add the directory to the System Path. For instructions on how to do this see this page.

Check setup

At this stage check that everything is setup correctly by running these commands in the command prompt.

Note. You will need to reopen the command prompt as the Path has been changed.

ruby -v
sqlite3 --version

Check Setup commands

Install Rails

To install rails run the following command (it may take a few minutes):

gem install rails

Check rails is installed properly by running:

rails --version

Rails Install Command Prompt

Ensure system is up to date

Just to make sure everything is up to date run:

gem update --system

Create a Blog Web Application

As a final test that everything is up and running a very simple Blog Web Application will be created.

1. Create a new Ruby on Rails application in your desired location. This will create a blog subdirectory.

rails new blog

2. Start web server in the blog subdirectory

cd blog
ruby bin\rails server

3. In a browser go to http://localhost:3000 to load the web application.

Blog Web Application

4. To get a handle on editing the application we’ll add “Hello” to a page

4.1 Create a new controller called “welcome” with action called “index” by running:

ruby bin\rails generate controller welcome index

4.2 Edit app\views\welcome\index.html.erb and replace all text with:

<h1>Hello!</h1>

4.3 Tell Rails where new home page is by editing config\routes.rb. Uncomment the following line:

root 'welcome#index'

4.4 Now restart rails server if you stopped it previously and reload http://localhost:3000 to see the updated page.

Blog Application with Hello

 

There you have it Ruby on Rails installed on to your system ready for you to develop. As time goes by there will be changes to this process, but I intend to keep this post up to date. But if you do see any errors please let me know by leaving a comment below or sending me an email at carmen@carmengrantham.com.


0 Comments

Leave a Reply

Avatar placeholder