Module: ApplicationHelper

Defined in:
app/helpers/application_helper.rb

Instance Method Summary collapse

Instance Method Details

#bootstrap_alert_class(key) ⇒ Object


14
15
16
17
18
19
20
21
22
23
24
25
# File 'app/helpers/application_helper.rb', line 14

def bootstrap_alert_class(key)
  suffix = case key.to_sym
    when :notice
      'info'
    when :error
      'danger'
    else
      key
    end

  "bg-#{suffix}"
end

#controller_nameObject


10
11
12
# File 'app/helpers/application_helper.rb', line 10

def controller_name
  params[:controller].gsub(/\W/, '-')
end

41
42
43
44
# File 'app/helpers/application_helper.rb', line 41

def excluded_portal_link
  controller_name == 'home' ||
  current_page?(carts_path)
end

#flash_listObject


35
36
37
38
39
# File 'app/helpers/application_helper.rb', line 35

def flash_list
  flash.map do |key, val|
    [key, flash_message(val)]
  end
end

#flash_message(val) ⇒ Object


27
28
29
30
31
32
33
# File 'app/helpers/application_helper.rb', line 27

def flash_message(val)
  if val.is_a?(Enumerable)
    val.join('. ')
  else
    val
  end
end

#humanized_options_for_select(options) ⇒ Object

Variation of git.io/ugBzaQ


3
4
5
6
7
8
# File 'app/helpers/application_helper.rb', line 3

def humanized_options_for_select(options)
  options = options.map do |val|
    [val.humanize, val]
  end
  options_for_select(options)
end