Skip to content

Instantly share code, notes, and snippets.

@ndunk28
Last active August 18, 2017 04:01
Show Gist options
  • Save ndunk28/888c89ac1a6cbb556397f8df02fe655e to your computer and use it in GitHub Desktop.
Save ndunk28/888c89ac1a6cbb556397f8df02fe655e to your computer and use it in GitHub Desktop.
simple active menu rails
def current_class?(test_path)
request.path == test_path ? 'active' : ''
end
<ul class="menu-list">
<li><%= link_to t('home'), root_path, :class => active_class(root_path) %></li>
<li><%= link_to t('products'), products_path, :class => active_class(products_path) %></li>
<li><%= link_to t('news'), news_index_path, :class => active_class(news_index_path) %></li>
<li><%= link_to t('contact'), contacts_path, :class => active_class(contacts_path) %></li>
<li><%= link_to t('about_us'), about_path, :class => active_class(about_path) %></li>
</ul>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment