RoR Helper - Menu Item with Current Class


/ Published in: Rails
Save to your folder(s)

Regular menu item adding current class if current url equal menu item destination.


Copy this code and paste it in your HTML
  1. def menu_li(label,url)
  2. @current_page = request.request_uri
  3. if @current_page == url
  4. '<li class="current"><a href="' + url + '" title="' + label + '">' + label + '</a></li>'
  5. else
  6. '<li><a href="' + url + '" title="' + label + '">' + label + '</a></li>'
  7. end
  8. end

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.