Return to Snippet

Revision: 28228
at July 4, 2010 19:18 by chrisaiv


Initial Code
#1. Insert this in /rails_app/helpers/application_helper.rb
def nav_link( text, controller, action="index" )
  link_to_unless_current text,  :controller => controller,
                                :action => action
end

#2. Make a Call from /views/layouts/application_helper.rb
<div id="nav">
    <%= nav_link "Home", "site" %>
    <%= nav_link "About", "site", "about" %>
    <%= nav_link "Help", "site", "help" %>
</div>

Initial URL


Initial Description
In an effort to stay DRY, here's a simple way to organize your main navigation.

Initial Title
Rails: Simple nav link helper

Initial Tags
rails

Initial Language
Rails