module ApplicationHelper def nav_items [ nav_item('Recipes', recipes_path, 'recipes'), nav_item('Ingredients', ingredients_path, 'ingredients') ] end def nav_item(name, url, controller) content_tag('li', link_to(name, url), class: active_for_controller(controller)) end def active_for_controller(controller) if current_controller == controller 'active' else '' end end def current_controller params[:controller] end end