I’m using this code to highlight currently active menu tab with Twitter Bootstrap:
def nav_link_to(link_text, link_path, options = nil)
class_name = current_page?(link_path) ? 'active' : ''
content_tag(:li, :class => class_name) do
link_to link_text, link_path, options
end
end
This of course makes the link active, only if the given link IS the current page.
How can I change this function, such that it would return ‘active’ for any links below current controller?
In other words, for all actions for Posts controller, the links would be active?
You can use
controller_nameto get the name of the current controller.