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!

Code Editor
Web Browser
Saving Data

Create messages I

Nice work! The app now displays a list of all messages in the database. How does this work?

The file index.html.erb is a web template. Web templates are HTML files that contain variables and control flow statements. Rather than write the same HTML over and over again for each message, we can use web templates to loop through and display data from the database.

In this case:

  1. <% @messages.each do |message| %> iterates through each message in @messages array. We created @messages in the Messages controller's index action.
  2. For each message, we use <%= message.content %> and <%= message.created_at %> to display its content and the time when it was created.

The default web templating language in Rails is embedded Ruby, or ERB.

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