Skip to content

Instantly share code, notes, and snippets.

@hooopo
Forked from greypants/README.markdown
Created August 8, 2012 14:12
Show Gist options
  • Save hooopo/3295339 to your computer and use it in GitHub Desktop.
Save hooopo/3295339 to your computer and use it in GitHub Desktop.
RAILS 3: nav_link helper for adding 'selected' class to navigation elements

#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.

@sharp
Copy link

sharp commented Aug 16, 2012

tabs_on_rails

@hooopo
Copy link
Author

hooopo commented Aug 16, 2012

@sharpx tabs on rails还要在controller里设置当前tab,很不爽。实现还用method missing更不爽。。

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment