Surpass Hosting

How to: Simple To-Do List

This tutorial covers the creation of a simple To-Do List application with Ruby on Rails. It assumes that you already have Ruby and Rails installed on your machine. (These instructions are available and up for discussion in our Community here.)

Step 1: Create the project

To create the "todo" project, open a terminal and run the following command:

rails todo


This will generate the directory structure and files needed for a Rails application. You can change your database connection info in config/database.yml, but I recommend just sticking with the default SQLite development database for now.

Step 2: Start the development server

Step 2: Start the development server

Next, we're going to start the Rails development server:

cd todo
script/server


Open up a browser and go to localhost:3000. You should see this page to the right.

Step 3: Generate the scaffolding

Rails has a useful command that lets us generate the models, views, controllers, migrations, and even tests for the basic CRUD (Create, Read, Update, Delete) operations of our application. Open a new terminal window and generate the scaffolding for our to-do items:

script/generate scaffold Item name:string description:text

Step 4: Run the migration

Run the migration that was automatically generated with the scaffold command to create our items table:

rake db:migrate

Step 5: Try it out

Step 5: Try it out

In your browser, go to localhost:3000/items. Here, you will find the CRUD interface for our to-do items we generated from the command line.

Step 6: Deploy your application

Developer Plan users can deploy their Ruby on Rails applications in just a few easy steps: Deploying a Ruby on Rails application on the Developer Plan.

For more information about Ruby on Rails, refer to the following links:

API: Rails Framework Documentation
Guide: Ruby on Rails guides
Phusion Passenger: Mod Rails Documentation

© Copyright 2002-2011 Surpass Hosting, LLC. All rights reserved.