/ Published in: Rails
In an effort to stay DRY, here's a simple way to organize your main navigation.
Expand |
Embed | Plain Text
#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>
You need to login to post a comment.
