Skip to content

Instantly share code, notes, and snippets.

@jpowers
Created November 2, 2010 15:52
Show Gist options
  • Select an option

  • Save jpowers/659818 to your computer and use it in GitHub Desktop.

Select an option

Save jpowers/659818 to your computer and use it in GitHub Desktop.
nav helper
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