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)
Written by Alexander Kirillov
Related protips
Have a fresh tip? Share with Coderwall community!
Post
Post a tip
Best
#Rails
Authors
Sponsored by #native_company# — Learn More
#native_title#
#native_desc#