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 - Ruby on Rails Tutorial
From the course: Ruby on Rails 5 Essential Training
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…
Practice while you learn with exercise files
Download the files the instructor uses to teach the course. Follow along and learn by watching, listening and practicing.
Contents
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
(Locked)
Challenge: AdminUser CRUD2m 44s
-
(Locked)
Solution: AdminUser CRUD7m 56s
-
(Locked)
Public area10m 35s
-
(Locked)
Public area navigation6m 3s
-
(Locked)
Nesting pages in subjects9m 44s
-
(Locked)
Nesting sections in pages7m 37s
-
(Locked)
Adding RubyGems: acts_as_list8m 25s
-
(Locked)
Finishing touches3m 30s
-
(Locked)
-