Other Pages

Intro To Rails

Goal

To teach you Ruby on Rails we are going to use a "Real World" example. You've decided to create a voting system for you and your friends to play with. You've decided at a minimum, you'd like to allow users to:

  • view the topics sorted by number of votes
  • vote on topics
  • create, edit, and destroy topics

You've sketched up an initial screenshot of what you want it to look like:

Browser window with topic titles that can be voted on, ordered by number of votes

Meta-Goal

When you have completed today's goal of getting the basic application online you should understand:

  • Basic Ruby syntax
  • How to try your Ruby code (IRB)
  • How to go from requirements to a new working Rails application
  • How to get your application online
  • The basic tools a RoR (Ruby on Rails) developer uses (source control, editor, console, local server)

Schedule

  • 1-ish hour of Ruby
  • 4-ish hours of Rails, broken up in 1-ish hour steps

This is just a rough guideline, not a mandate. Some steps you'll go over and some you'll go under. It'll all work out by the end of the day. Probably.

Requirements

To get through this course, you'll need a free Github account.

Create a free Github account by filling the signup form.

On the next screen, you can click Skip personalization on the bottom to continue.

Once you are signed into Github, you'll need to create a repository - a new programming project.

To do that, create a new repository from the RailsBridge template.

You can pick any name you like, or accept the default suggestion. You can also decide if you want your code to be public for anyone to see, or private.

Click Create repository to continue.

It may take a moment for your repository to be generated.

When it's finished, you'll be taken to a page that looks like this. Click on the green Code button, make sure you're on the "Codespaces" tab, then click Create codespace on main. This will be our code editor.

This will begin setting up the editor in your browser. This usually takes at least 2 - 3 minutes.

The editor will automatically set up like this once it's ready.

Congratulations! You're ready to start coding.

Working Effectively and Efficiently

We highly recommend you do the following:

  • In your codespace you will want to open 2 terminal tabs::
    • One will be for executing terminal commands and using the Rails console.
    • One will be for running your server, so you can test your app as you code (you can't use the terminal for anything else when the server is running).
  • Open your browser fresh or hide any windows you already have open.
    • Bring up one window with two tabs
    • One for this content
    • One for interacting with your app.
  • Open your text editor and don't close it.
  • Hide all extra applications. Turn off Twitter, Facebook, IM, and all other distractions.

By minimizing the number of things you interact with, you reduce the amount of time spent switching between them and the context lost as you work through the lessons. Having 50 tabs open in your web browser gets confusing.

Format

Each lesson will look like this:

Step Title

Goal:

Description of the current step.

Red because big goals are important.

Steps:

steps to take.
def code_to_write
  1 + 1
end

Yellow because we've gotten it done, but we're not sure yet what's going on.

Explanation

Details of what the steps actually did, explaining the cause and effect.

Green because we can tie everything together now.

Next Step: