parsley/app/helpers/application_helper.rb
2016-01-12 18:43:00 -06:00

25 lines
495 B
Ruby

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