The simple tab-like menu or sidebar is the most common user interface element on the Web. In this section, you'll see how to create a simple menu using some HTML and Rails-supported logic.
5.1.1. Single-Level Menus
Rails, unsurprisingly, has some built-in-support for the logic needed to manage a menu list. The logic involved is to simply display a link to another page unless that page is the active page, in which case do something else — usually display the text without the actual link. The Rails method is link_to_unless_current, and you use it in a menu something like this:
This is a drop-in replacement for the Navigate sidebar in the recipes.html.erb layout file. Because you're going to want this to become rather generic, put this code in a partial — I call mine app/views/shared/_navigation_sidebar.html.erb. Then you can drop in the call from the layout file like ...
With Safari, you learn the way you learn best. Get unlimited access to videos, live online training,
learning paths, books, interactive tutorials, and more.