How to add "active" HTML class in Ruby on Rails
module ApplicationHelper
def link_active?(path)
"active" if request.path.include?(path)
end
end
<%= link_to "Articles", articles_path, class: "#{link_active?(articles_path)}" %>
module ApplicationHelper
def link_active?(path)
"active" if request.path.include?(path)
end
end
<%= link_to "Articles", articles_path, class: "#{link_active?(articles_path)}" %>