Last Updated: February 25, 2016
·
918
· saratovsource

current_page?(options) method for current page class

Use current_page? method for checking current page path.

Helper file:

def page_class(path, default_class = "active")
  default_class if current_page?(path)
end

In your views:

=link_to 'Any link', path, class: page_class(path)