The nav_link_to helper works just like the standard Rails link_to helper, but adds a 'selected' class to your link (or its wrapper) if certain criteria are met. By default, if the link's destination url is the same url as the url of the current page, a default class of 'selected' is added to the link.
<%= nav_link_to 'My Page', my_path %>
my_path is the same as the current page url, this outputs:
<a class="selected" href="http://example.com/page">My Page</a>
For more options and full usage details, see: http://viget.com/extend/rails-selected-nav-link-helper
Usage with blocks:
Same usage as
<%= nav_link_to 'http://example.com/page' do %> <strong>My Page</strong> <% end %>
- Add this to your Gemfile and then
nav_link_tohelper in your views.