0Pricing
Ruby Academy · Lesson

Views and Rendering

Returning responses.

What Is a View?

A view is a template that produces the response sent to the client, usually HTML. It turns the data a controller prepared into a page.

  • Views live in app/views.
  • They are grouped by controller, like app/views/articles.
  • The default template name matches the action.

Convention-Based Rendering

By default an action renders the template named after it. The index action of ArticlesController renders app/views/articles/index.html.erb with no explicit render call.

def index
  @articles = Article.all
  # automatically renders articles/index.html.erb
end

All lessons in this course

  1. Routes and Resources
  2. Controllers and Actions
  3. Strong Parameters
  4. Views and Rendering
← Back to Ruby Academy