It's a problem after using the solution here Best way to add "current" class to nav in Rails 3
def nav_link(link_text, link_path)
class_name = current_page?(link_path) ? 'current' : ''
content_tag(:li, :class => class_name) do
link_to link_text, link_path
end
end
For example, I have localhost/action1
, and localhost/action2
, each with a nav button.
It works great when user is in either page. In this situation, one of the button would have a 'current' css class.
But, if I set root_path
to one of them, let's say is the /action1
, so when user visit localhost
, the button for action1
won't have a current
class
How can I solve add the missing current
css class when setting it as the root_path
?