Newbie help re: "dynamic" navigation menu


I am trying to get my head around how you would “efficiently” do a
left-hand navigation menu structure derived from various database table

Example is loosely based on AWDwR’s depot app. Say you wanted to
instead to have the left-hand nav links show the following:
book title 1
book title 2

CD title 1
CD title 2

with the main page area showing a single book or CD info based on what
was selected in the menu.

The titles in the menu would be generated on the fly by doing d/b finds
from books and CDs tables. The links on the titles would go to the
store controller, with actions like ‘show_book’ for books and ‘show_cd’
for CDs.

What I am concerned about is wouldn’t each of these methods need to set
instance vars for the collections of book and CD titles each time, so
the main store view can render the menu? This seems to go against the
DRY principle and not taking advantage of caching (particularly if the
titles don’t change much).

I’m sure a different view “hierarchy” and partials or AJAX is required
to make this work better, but I need some guidance on how to go about


Look into using fragment caching. You can cache sections of a page, so
can keep the content of your page dynamic, while making your menu stay
same, until you update your list.

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs