Other Pages

Expand All

Getting Started

Screenshot of a Ruby on Rails default home page

Goals

  • Create Your New Application

  • Let's get started! By the end of this step, we'll have a brand-spankin'-new (empty) Rails app.

Steps

If you have any problems, call over a TA.

Step 1

cd stands for change directory.

A directory is the same thing as a folder.

Option 1.1: Windows

Type this in the terminal:
cd c:\Sites

cd c:\Sites sets our Sites directory to our current directory.

Option 1.2: Mac or Linux

Type this in the terminal:
cd ~

cd ~ sets our home directory to our current directory.

Step 2

Type this in the terminal:
mkdir railsbridge

This command creates a new directory for us to store our project in.

Step 3

Type this in the terminal:
cd railsbridge

Step 4

Check to see if you have any existing suggestotron apps from a previous workshop.

OSX/Linux
Type this in the terminal:
ls

ls stands for list.

It lists the contents of the current directory.

If you have any old suggestotron apps in that list, you can remove them to prevent hiccups:

Type this in the terminal:
rm -rf suggestotron
Windows
Type this in the terminal:
dir

dir stands for directory.

It lists the contents of the current directory.

If you have any old suggestotron apps in that list, you can remove them to prevent hiccups:

Type this in the terminal:
rmdir /s /q suggestotron

Step 5

Type this in the terminal:
rails new suggestotron

rails new creates a new Rails project with the name you give.

In this case we told it to create a new project called suggestotron. We'll go into detail on what it created shortly.

This will print a lot of stuff to the screen and can take a while to finish.

Step 6

Type this in the terminal:
cd suggestotron

cd suggestotron makes suggestotron our current directory.

Step 7

Open the suggestotron folder as a project in your text editor.

Close any files that are already open. They might be from yesterday's test_app, and we want to make sure that we're editing files in today's suggestotron app.

In Sublime Text 2, you can use the Project > Add Folder to Project... menu option:

Sublime Text Project menu screenshot

Select your suggestotron folder from the file picker that opens. If everything works out Sublime should show the directories of your app in a tree structure on the left:

Screenshot of Suggestotron project folder tree in Sublime Text

You can see that rails new created a lot directories and files. The ones we want to focus on today are:

File/Folder Purpose
app/ Contains the controllers, models, and views for your application. You will do most of your work here.
config/ Configure your application's runtime rules, routes, database, and more.
db/ Shows your current database schema, as well as the database migrations.
public/ The only folder seen to the world as-is. If you put files in here, they will be served directly without any processing by Rails.
app/assets/ This is where your images, JavaScript, stylesheets (CSS), and other static files should go. Modern Rails apps use something called the Assets Pipeline, which combines all the JavaScript and CSS files in this directory into a single file for speediness.

There is a lot more that rails new created. Probably enough to fill a book, so we're going to ignore them for now.

Next Step: