/ Published in: Rails
I needed to make menu items that kept the current class based on the controller being accessed.
Expand |
Embed | Plain Text
Copy this code and paste it in your HTML
def top_menu_li(label,controller,url) @current_page = request.request_uri @current_controller = request.path_parameters['controller'] if @current_page == url || @current_controller == controller '<li class="current"><a href="' + url + '" title="' + label + '">' + label + '</a></li>' else '<li><a href="' + url + '" title="' + label + '">' + label + '</a></li>' end end