Files
mozo-backend/app/helpers/application_helper.rb
T
2012-08-29 17:42:04 +02:00

57 lines
1.4 KiB
Ruby

module ApplicationHelper
def title(*args)
content_tag :h1 do
if args.first.is_a?(Symbol) && (args[1].respond_to?(:model_name) || args[1].class.respond_to?(:model_name))
model = args[1].respond_to?(:model_name) ? args[1] : args[1].class
if args.first == :index
t('action.index.label', models: model.model_name.human_plural)
else
t("action.#{args.first}.label", model: model.model_name.human)
end
else
args.first
end
end
end
def are_you_sure?
t('helpers.links.are_you_sure')
end
def active_list
active_list_object
end
def application_title
'Qwaiter'
end
# Helper for displaying HTML currency values
def currency(amount, opts={})
amount ||= 0.0
amount = amount.to_f
#prefix = case company.currency
# when 'GBP' then '£ '
# when 'USD' then '$ '
# else '€ '
# end
prefix = '€ '
return (prefix + ("%.2f" % amount)).html_safe
# Rails native is ambiguous since is uses translation hashes
options = {:unit => '€'}.merge(opts)
number_to_currency(amount, options)
end
def list_open?
active_list_id.present?
end
def active_list_id
current_user.try(:active_list_id)
end
def no_content_given(model)
t('helpers.list.no_records')
end
end