I'd like to set up some persistent navigation at the top of my web pages and a good place to do this seems to be in application.rhtml. The sitepoint ruby book demonstrates something along the lines of this:
I'm running into problems because I'd like to have my navigation link to some dynamically created topic pages. That is, I've got a model called Topic that can have many stories (a story belongs to a topic). In my example, I've got two topics, "sports" and "art", and I want my navigation to have links to both of them. I need some way to identify the various topics and was thinking of using a loop such asCode:
<li><%= link_to 'Front page stories',
:controller => 'story' </li>
<li><%= link_to 'Submit a new story',
:controller => 'story', :action => 'new'%></li>
<% for topic in @topics %>
My few attempts at working this out haven't worked. Do I need to create an instance variable in application.rb called @topics? How do I access it? Is there a better way to do this?