我的application_helper.rb文件中有以下帮助器:
def topmenu pages = { "projects" => projects_path,"photos" => photos_path } pages.map do |key,value| classnames = %( class="current") if controller.controller_name == key "<li#{classnames}>#{link_to(key,value)}</li>" end end
然后在我的application.html.erb文件中,我有:
<%= topmenu %>