# Navigation

**URL:** <https://www.ruby-forum.com/t/navigation/95695>\
**Category:** Rails\
**Created:** [December 7, 2005, 8:20am UTC](https://www.ruby-forum.com/t/navigation/95695 "2005-12-07T08:20:27Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![jpfeifer](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/65b543/32.png) [@jpfeifer](https://www.ruby-forum.com/u/jpfeifer)\
**Post date:** [December 7, 2005, 8:20am UTC](https://www.ruby-forum.com/t/navigation/95695/1 "2005-12-07T08:20:27Z")

</div>

Greetings,

I appreciate the help from here as I seem to be asking the noob  
questions a lot, but what is a good way to deal with navigation pulled  
from a database?

I have this in my view:

\<% @nav\_buttons.each do |nav\_button| %\>

- \<%=h nav\_button.name %\>
  
\<% end %\>

this in my controller

def index  
shownav  
end  
def shownav  
@nav\_buttons = NavButton.find(:all)  
end

and I want to make it so that one of the class=“nav” list items has an  
id=“active” decided by a default variable for the homepage, which I will  
assign a value to as another section is clicked. I realize this is  
probably pretty micky mouse for most on this list, but I promise once I  
am up to speed on rails a bit more I’ll help the new guys around here  
🙂

Cheers,

Jason

---

<div class="post-metadata">

**Author:** ![jpfeifer](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/65b543/32.png) [@jpfeifer](https://www.ruby-forum.com/u/jpfeifer)\
**Post date:** [December 7, 2005, 6:28pm UTC](https://www.ruby-forum.com/t/navigation/95695/2 "2005-12-07T18:28:50Z")

</div>

Hi Jason,

I’ll give this a shot:

Let’s say you store the active button name in a variable called  
@active\_button\_name.

In your view, you could just add this into the href link:

\<%= ‘id = “active”’ if nav\_button.name == @active\_button\_name %\>

So, this would change your view code to:

\<% @nav\_buttons.each do |nav\_button| %\>

- \>\<%=h nav\_button.name %\>
\<% end %\>

Tom

---

<div class="post-metadata">

**Author:** ![jpfeifer](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/65b543/32.png) [@jpfeifer](https://www.ruby-forum.com/u/jpfeifer)\
**Post date:** [June 4, 2009, 4:26pm UTC](https://www.ruby-forum.com/t/navigation/95695/3 "2009-06-04T16:26:54Z")

</div>

I fixed it modifying the core radiant.  
There is a simple way to contribute?

---

<div class="post-metadata">

**Author:** ![jpfeifer](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/65b543/32.png) [@jpfeifer](https://www.ruby-forum.com/u/jpfeifer)\
**Post date:** [June 4, 2009, 3:45pm UTC](https://www.ruby-forum.com/t/navigation/95695/4 "2009-06-04T15:45:31Z")

</div>

Rafael,

Try adding slashes on the ends of your URLs; and yes, \<r:navigation\> has  
pretty primitive matching of URLs.

Sean

---

<div class="post-metadata">

**Author:** ![jpfeifer](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/65b543/32.png) [@jpfeifer](https://www.ruby-forum.com/u/jpfeifer)\
**Post date:** [June 4, 2009, 4:32pm UTC](https://www.ruby-forum.com/t/navigation/95695/5 "2009-06-04T16:32:50Z")

</div>

Fork. Branch. Spec. Code. Pull Request.

---

<div class="post-metadata">

**Author:** ![jpfeifer](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/65b543/32.png) [@jpfeifer](https://www.ruby-forum.com/u/jpfeifer)\
**Post date:** [June 4, 2009, 4:38pm UTC](https://www.ruby-forum.com/t/navigation/95695/6 "2009-06-04T16:38:45Z")

</div>

Someone should put that on a sign or t-shirt!

Sean
