module ApplicationHelper def title(*args) res = content_tag :h1, class: 'page-title' 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 content_for :page_title, res res end # overwrite i18n l, to handle nil values def l(*args) return '' unless args.first super(*args) 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 def slider_image image_tag('spinner.gif') end def show_boolean(bool) t("general.boolean.boolean_#{bool.present? ? 'yes' : 'no'}") end end