Home > Instruction > Setting up your environment for rails

Setting up your environment for rails

This instructional document will demonstrate how to prep your computer for developing with the Ruby on Rails framework. It should take no more than 30 minutes to complete.

In this document, you will complete the following tasks:

REQUIREMENTS

In order to make the most of this instructional document, the following operating systems are recommended:

Ubuntu or Mac OS X

http://www.ubuntu.com/
http://apple.com/

Prerequisite knowledge

This instructional document does not require that you understand Ruby on Rails. However, familiarity with osX or Ubuntu (debian) Linux will be helpful. This document is not designed for use with Windows. This instructional document is designed to be completed from top to bottom. More information can be found on this topic at One-Click Ruby Installer.

CHECK TO SEE IF RUBY IS INSTALLED

Let’s start by making certain the ruby language is installed, specifically version 1.8.7. This is usually a part of the osX and Linux operating systems.

Execute the following command:

$ ruby --version

INSTALLING THE RUBY LANGUAGE

If the Ruby language is not installed on your system, you can install this version in two ways:

  1. Installing a pre-compiled package
  2. Compiling the source code

For brevity and an easier upstart, I will use a pre-compiled package. The main package managers in the associated operating systems are “port” (osX) or “aptitude” and “apt-get” (linux). If you are not familiar with either, a simple Google search on the name and the language should help. Using a port on my computer took about 10 minutes.

Install ruby from package (osX)
$ sudo port install ruby

Install Ruby from package (Ubuntu Linux)
$ sudo apt-get install ruby

INSTALL THE RUBYGEMS PACKAGE MANAGER

Next we will install the Ruby package manager. Yes, another package manager just for Ruby! While this may seem overwhelming at first, keep in mind the Rubygems package manager is an integral part of using ruby and rails. It will allow us to install “gems” that are packaged up ruby code that is available from others. Begin by downloading the latest version of rubygems in either *.tgz or *.zip format. After the download is complete, uncompress the file and execute setup.rb. The commands are groups below:

* note – wget is a command that will download the file given to your current directory. You can download it with a web browser, but wget will definitely be faster and keeps our work in the terminal (shell).

$ wget http://rubyforge.org/frs/download.php/57644/rubygems-1.3.4.zip
$ unzip rubygems-1.3.4.zip
$ cd rubygems-1.3.4
$ sudo ruby setup.rb

INSTALLING THE RAILS FRAMEWORK

With gem installed, we are now able to install the rails framework. You can do so by executing the command below. It will install rake, activesupport, actionpack, actionmailer, activeresource, all of which are necessary for rails.

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

INSTALLING SQLITE3

Next, we need to install Sqlite3. It is a text based sql database. It will be how our rails applications store data for and from our webpages. Again, this may already be installed depending on the operating system. We will be going back to port and apt-get for this installation.

Install sqlite3 from package (osX)
$ sudo port install sqlite3

Install sqlite3 from package (ubuntu linux)
$ sudo apt-get install sqlite3

Now install sqlite-ruby bindings with gem
$ sudo gem install sqlite3-ruby

CREATING A NEW RAILS APPLICATION

Finally, let’s finish by creating a new rails application and then start it to see the site.

$ cd /some/directory/for/your/projects
$ rails starter-project
$ cd starter-project
$ ruby script/server

* additionally – if you want the server to start on another port than the default (3000), this script/server command can be executed with the -p attribute

$ ruby script/server -p 8000

Visit the site now running on your computer. This link uses the default port of 3000.

Congratulations, your environment is ready for developing this new rails application! More can be found on creating rails applications in my next article.

Categories: Instruction Tags: , ,
  1. No comments yet.
  1. No trackbacks yet.
Google Analytics Alternative