RoR Helper - Top Section Menu


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

I needed to make menu items that kept the current class based on the controller being accessed.


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

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.