Module: Sal::ApplicationHelper

Defined in:
app/helpers/sal/application_helper.rb

Instance Method Summary collapse

Instance Method Details

#errors_bar(*entities) ⇒ Object



3
4
5
6
7
8
9
10
11
12
13
14
15
16
# File 'app/helpers/sal/application_helper.rb', line 3

def errors_bar(*entities)
  entities = Array(entities)

  messages = entities.map { |entity| entity.errors[:base].map &:capitalize }.flatten

  # is there any non-base error?
  if entities.detect { |entity| entity.errors.keys.detect { |error| error != :base } }
    messages << t(:errors_bar_message)
  end

  if messages.any?
     :div, messages.join("\n"), class: 'alert alert-danger'
  end
end


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

def menu_item(item, tag = :li)
  options = section == item ? {class: 'active'} : {}
   tag, options do
    yield
  end
end


33
34
35
36
37
38
# File 'app/helpers/sal/application_helper.rb', line 33

def menu_items(set)
  @_set = set
  output = yield
  @_set = :menu
  output
end

#messages_barObject



18
19
20
21
22
23
24
# File 'app/helpers/sal/application_helper.rb', line 18

def messages_bar
  if notice
     :div, notice.html_safe, class: 'alert alert-success'
  elsif alert
     :div, alert.html_safe, class: 'alert alert-warning'
  end
end