Ruby Ruby on Rails 5 Basics Handling Requests The Controller

gene c
gene c
13,630 Points

render template: "posts/index.html.erb", layout: "application"

I really don't understand what this is doing? what is render template and what does layout signify

Shaneil Clarke
Shaneil Clarke
4,630 Points

A template will be rendered automatically by rails that has the same name of the action.
render template: "posts/index.html.erb" is specifying which template to render, in this example they loaded the same that would have been rendered anyways.
layout: "application" is a default place you put HTML you want to be rendered on multiple pages. This prevents you from repeating the same HTML multiple places.