#Behold, the nav_link:
The nav_link 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.
For full usage details, see: http://viget.com/extend/rails-selected-nav-link-helper
Drop nav_link_helper.rb into app/helpers in your Rails 3.x app and enjoy.
#About this fork
This particular fork allows you to pass a block to the helper method like so:
= nav_link "News", articles_path, {class: "btn btn-small"}, {selected_class: 'active'} do
%i.icon-home
Which would create the following html:
<a href="/articles" class="btn btn-small active">
<i class="icon-home"></i>
News
</a>
If no block is given, then nav_link helper behaves as normal.
Yay. Thanks to Viget labs for doing all the hard-work on this.