Installing Ruby on Rails
The programming projects for this class require you to use Ruby 1.9.3 and
Rails 4.0.0. If you don't already have these packages installed on your laptop,
follow the instructions below to install them.
The installation process is different depending on whether you
are running Windows, MacOS, or Linux:
Windows
- There is an all-in-one installer available at
http://railsinstaller.org/.
Click on the large "Download Kit" button and follow the instructions.
This will install Ruby, Rails, Sqlite, plus a few other things such
as git.
- Once the installer has completed, open a command window and type
the following command to upgrade to Rails 4.0.0:
gem install rails -v 4.0.0
Mac OS X
- Recent versions of Mac OS X have Ruby and Rails installed by default,
but you will need to upgrade to version 1.9.3 of Ruby and version 4.0.0
of Rails.
- To get started, you will need to install XCode, but note that
you will NOT be developing in XCode, you just need to have it
installed. You can grab the dmg file here:
http://developer.apple.com/technology/xcode.html. We recommend
the iPhone version if you have any interest in doing iPhone dev
at any point. Also, you'll have to sign up for a free ADC account
to download XCode.
- If you are running Mavericks, you can use a simpler approach to
installing XCode, which will install a lot less junk on your machine.
Instead of following the instructions above, open a shell window
and enter the following command:
sudo xcode-select --install
A popup window will appear asking for permission to install; go ahead
with that. Once the installation finishes, invoke the following
command in the shell window:
After this command completes, exit the shell window (e.g. CMD+Q) and start
a new shell window; use that new window for the rest of the commands
below.
- If you don't already have gcc installed, you will need to install it.
To see if gcc is already installed, type "gcc" in a shell window and see
if the command is found. If not, you can get gcc from
https://github.com/kennethreitz/osx-gcc-installer/downloads.
- Check your version of Ruby by typing "
ruby -v"
in a shell window. If you are not running version 1.9.3, you will
first have to install rvm
, then use it to upgrade
Ruby. To install rvm
, follow the instructions at
https://rvm.io/rvm/install/.
Once rvm
is installed, upgrade Ruby with the following
shell commands:
rvm install 1.9.3
rvm use 1.9.3 --default
- Once you are running Ruby 1.9.3, you can upgrade to Rails 4.0.0
with the following command:
gem install rails -v 4.0.0
- Install Sqlite3. Mac OS X should already have Sqlite3 pre-installed,
so all you need to do is install the Ruby connector:
This may print out several warning messages, which you can ignore.
If this prints error messages, it may be that you don't have Sqlite3
pre-installed; Google "sqlite3 install macos" to find out how
to install it.
Linux
We don't officially support Linux for this class, so you will be mostly on your
own if you want to use it. However, we think the following instructions may
work:
- Check to see if Ruby is already installed with the correct version
by typing "
ruby -v"
. If it prints version 1.9.3 then
you can skip the next few steps.
- Install
rvm
by following the instructions at
https://rvm.io/rvm/install/.
This page gives several possible commands for installing rvm
;
we recommend the following command:
\curl -sSL https://get.rvm.io | bash -s stable --ruby
-
Once
rvm
is installed, invoke the following shell commands,
which will upgrade Ruby to 1.9.3 and make that the default version of
Ruby on your machine.
rvm install 1.9.3
rvm use 1.9.3 --default
- Once you are running Ruby 1.9.3, you can upgrade to Rails 4.0.0
with the following command:
gem install rails -v 4.0.0
- Install Sqlite3. Download the file
sqlite-3.7.0.1.so
and copy it to the directory
containing the Ruby executable. Then use the
Gem system to install the Ruby connector:
This may print out several warning messages, which you can ignore.
- Some Linux distributions come with Ruby 1.9.3 already installed. You can
use this to skip some of the installation steps above, but if you do this,
you may need to run some of the other installation commands above using
sudo
(e.g. "sudo gem install rails -v 4.0.0
"
instead of "gem install rails -v 4.0.0
")
- If you use
apt-get
to install packages, you may also
need to use sudo
in some of the commands above.
- When using a GUI terminal to run
rvm
properly, you should
set the terminal as a login shell; see
https://rvm.io/integration/gnome-terminal for instructions.
- Installations can take quite a bit of time (several minutes)
before showing any output.
- You can ignore warning messages about Ruby 1.9.3 going out of
maintenance.