O'Reilly logo

Learning Ruby by Michael Fitzgerald

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

A Brief Tutorial

There are other sources for Rails tutorials, but I can't resist the temptation to provide one here for you. It will be brief and very gentle on you—just enough to get your feet wet. Don't think too hard; just follow the step-by-step instructions and let the process sink in. I'll provide some tips along the way.

I'll use Rails to create a simple address book on Mac OS X; Unix/Linux will be very similar, but you will have to translate the steps a little if you are on Windows. These instructions assume that Rails and MySQL are already installed. If you used the HiveLogic or Instant Rails instructions under "Other Installation Information," you should be set to go.

In a shell window, move to your home directory, and just for sanity, test the existence of Rails and MySQL. Then create a directory where you will generate the Rails project (address), and change directories to that new location.

$ cd ~/
$ rails --version
Rails 1.2.3
$ mysql --version
mysql  Ver 14.12 Distrib 5.0.27, for apple-darwin8.6.0 (powerpc) using readline 5.0
$ mkdir address
$ cd address

So far so good? Now run the rails command with the name addressbook, and Rails creates a number of directories and files.

$ rails addressbook
      create
      create  app/controllers
      create  app/helpers
      create  app/models
      create  app/views/layouts
      create  config/environments
      create  components
      create  db
      create  doc
      create  lib
      ...

At this point you have a Rails application in skeletal form. In a matter of seconds, Rails has done an unbelievable ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required