parsley/app/helpers/application_helper.rb

30 lines
564 B
Ruby
Raw Normal View History

2016-01-12 18:43:00 -06:00
module ApplicationHelper
2016-01-18 15:10:25 -06:00
def timestamp(time)
time ? time.strftime('%D %R') : ''
end
2016-01-12 18:43:00 -06:00
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