Posted By

smoothdzion on 12/18/09


Tagged

rails helper ror


Versions (?)

Who likes this?

1 person have marked this snippet as a favorite

smoothdzion


RoR Helper - Top Section Menu


 / Published in: Rails
 

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

  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  

You need to login to post a comment.