Other Pages

Expand All

Getting Started

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, contact a TA immediately.

Step 1

cd stands for change directory.

If you are still in IRB, type quit to exit.

Windows
Type this in the terminal:
cd c:\Sites

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

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.

Windows
Type this in the terminal:
dir

That command will list the files in your railsbridge directory. If you have any old suggestotron apps in that list, you can remove them to prevent hiccups:

Type this in the terminal:
delete suggestotron
Mac or Linux
Type this in the terminal:
ls

That command will list the files in your railsbridge 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

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.

Step 6

Type this in the terminal:
cd suggestotron

'cd' stands for change directory.

'cd suggestotron' makes suggestotron our current directory.

Step 7

If you are using a Mac

Type this in the terminal:
ls

If you are using a PC running Windows

Type this in the terminal:
dir

'ls' stands for 'list (stuff)'. It shows you the contents of the current folder.

Step 8

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

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

Select your suggestotron folder from the file picker that opens. If everything works out Sublime should look something like this:

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.

Great! You've created a brand new (empty) Rails app!

Why not take a break and stretch your legs?

Next Step:

Back to Ruby Language

If you find something that could be improved, please make a pull request or drop us a note via GitHub Issues (no technical knowledge required).

Source: https://github.com/RailsBridge-CapeTown