How to get current controller for a URL in Rails?
- by valk
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?
Thanks.