Prev Lesson | TOC | Next Lesson

Topics

Creating a migration

Goal:

topics_table

The suggestotron has a list of topics that people can vote on. We'll store our topics in the database. In this step you'll do the following:

In this step we'll learn a bit about MVC (Model-View-Controller) architecture. By the end of this step you should understand the following concepts:

Steps:

Try the following in your terminal:

$ rails generate scaffold topic title:string description:text
$ rake db:migrate
$ rails server

If you want, take some time to poke around the files listed in the generate step.

What Just Happened?

rails generate scaffold topic title:string description:text

Explaining MVC and Records

mvc

Rails implements a very specific notion of the Model View Controller pattern, which guides how you structure your web applications.

Model

View

Controller

In MVC, models, views, and controllers have very specific jobs. Separating responsibilities like this make it easy to maintain and extend rails applications. When responsibilities become muddied it gets much harder to debug issues and add new functionality.

Prev Lesson | TOC | Next Lesson