From the course: Ruby on Rails 5 Essential Training

Unlock the full course today

Join today to access over 22,600 courses taught by industry experts or purchase this course individually.

Layouts

Layouts - Ruby on Rails Tutorial

From the course: Ruby on Rails 5 Essential Training

Start my 1-month free trial

Layouts

- [Instructor] Throughout this chapter, we'll be learning techniques for managing view templates and exploring Rails view helpers. We're gonna begin by looking at layouts. Most pages on a website are going to share a common structure: the header, the footer, the style sheet, and possibly other side items, like navigation menus or sidebars. At the end of the last chapter, we saw one example of this, using the flash hash, which we want to appear on every page which might need to render a flash message. It makes the most sense if we could define those shared page elements in one place and then reuse them. Remember, "don't repeat yourself" is one of our core principles, and that's exactly what a layouts help us to do. Up until now, the templates we've been working with have been html fragments, not proper html pages with header and body tags. That was intentional on my part because now we'll be able to drop those fragments into a layout. Let's take a look at a simple Rails layout. Here I…

Contents