Click here to navigate the course.

Drag the edges to resize the window.

In Projects, you can keep track of your progress as you go throught the tasks. Check each item as you complete it!

Web Browser

Code Editor
Terminal
Learn

Nice work. We added a controller and a route to the Rails app.

Why does the Messages controller use an action named index? Check out the diagram in the browser. Rails provides seven standard controller actions for doing common operations with data. Here we want display a list of all messages, so we used the index action.

Putting it all together:

  1. When a user visits http://localhost:8000/messages, the routes file maps this request to the Messages controller's index action.
  2. The index action retrieves all messages from the database and stores them in variable @messages.

The @messages variable is passed on to the view. The view should display each message, so let's set it up next.

Instructions

Now that we have a model, controller, and route, let's move on to the fourth part of the request/response cycle and create a view.

Report a Bug
If you see a bug or any other issue with this page, please report it here.