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.

Nesting sections in pages

Nesting sections in pages - Ruby on Rails Tutorial

From the course: Ruby on Rails 5 Essential Training

Start my 1-month free trial

Nesting sections in pages

- [Narrator] At the end of the last movie, I asked you to try on your own, to nest these sections inside the pages. In this movie, let's take a look at it. First, let's take a look at what the end results look like. We have one link for manage content now. When I click on that, I get a list of my subjects. When I click view pages, I get a list of the pages for that subject. When I click view sections, I get a list of these sections for that page only. Notice up here that page ID is being maintained, and as I click around, Page ID is always still there. So these are always scoped by this page. Let's take a look at the code. The first thing I did, was I went into pages index, and I added this view sections link. That's gonna go to the sections path. The list of sections and pass in page ID at the same time. Then, I went into my sections controller, and I added a new before action for find page. I added a new method, down here at the bottom, for finding that page. And it assigns the page…

Contents