Created
November 2, 2010 15:52
-
-
Save jpowers/659818 to your computer and use it in GitHub Desktop.
nav helper
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| def nav_item(title, url) | |
| active_class = current_path?(url) ? ' class=\'active\'' : '' | |
| content = '<li' + active_class + '>' | |
| content << capture do | |
| link_to title, url | |
| end | |
| content << content_tag(:span) << '</li>' | |
| content.html_safe | |
| end | |
| def current_path?(path) | |
| Rails.application.routes.recognize_path(path) == {:controller => controller.controller_path, :action => controller.action_name} | |
| end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment