1

I have the following navigation HTML:

<nav class="col9">
      <ul>
        <li class="current"><a href="/">Home</a></li>
        <li><a href="/">About</a></li>
        <li><a href="/">Apps</a></li>
        <li><a href="/">Blog</a></li>
        <li><a href="/">Contact</a></li>
      </ul>
</nav>

I need to find a way to dynamically add the class of "current" to the relevant list item (if we are on the page).

I have the following code in my application_helper.rb:

def menu_link(name, options = {}, html_options = {})
        html_options.merge!({ :class => 'current'}) if current_page?(options)
        link_to name, options, html_options
    end

However, this adds the class of current to the anchor tag instead of the list item. Would anyone be able to assist me in modifying this?

Cheers.

J. Steen
  • 15,470
  • 15
  • 56
  • 63
Ammar
  • 1,091
  • 12
  • 23
  • 1
    possible duplicate of [Best way to add "current" class to nav in Rails 3](http://stackoverflow.com/questions/3705898/best-way-to-add-current-class-to-nav-in-rails-3) – Skilldrick Oct 13 '11 at 15:14

0 Answers0