Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

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

1 Answer

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.