From the course: Ruby on Rails 5 Essential Training
Unlock the full course today
Join today to access over 22,400 courses taught by industry experts or purchase this course individually.
Public area navigation - Ruby on Rails Tutorial
From the course: Ruby on Rails 5 Essential Training
Public area navigation
- [Narrator] In the last movie we created a public controller and enabled it to display pages from our CMS but to view those pages we had to type their names directly in the browser's URL bar. Let's now create a navigation for the public area by listing the available pages by their subject. Each page is going to be a clickable link then users can navigate our site and view different pages just by clicking on the navigation links. We're going to want our navigation to appear on every single page inside the public controller. And the navigation is going to want us to have a list of all the subjects available so then we can go through each subject and get all of it's pages. So this is a perfect example of some housekeeping that we can do with a before action. Before_action :set up_navigation. This will perform whatever we need to do to set up the navigation so it's ready to use for all of the pages. Private def set up_navigation. Inside that method what do we want to do? We want to find…
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.