application_helper.rb
1.08 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
module ApplicationHelper
def display_base_errors resource
return '' if (resource.errors.empty?) or (resource.errors[:base].empty?)
messages = resource.errors[:base].map { |msg| content_tag(:p, msg) }.join
html = <<-HTML
<div class="alert alert-error alert-block">
<button type="button" class="close" data-dismiss="alert">×</button>
#{messages}
</div>
HTML
html.html_safe
end
def bootstrap_class_for(flash_type)
case flash_type.to_s
when "success"
"alert-success" # Green
when "error"
"alert-danger" # Red
when "alert"
"alert-warning" # Yellow
when "notice"
"alert-info" # Blue
else
flash_type
end
end
def request_status_label(status)
classes = [ 'label' ]
case status
when 'created'
when 'processing'
classes << 'label-warning'
when 'error'
classes << 'label-important'
when 'success'
classes << 'label-success'
end
content_tag(:div, t(status, scope: 'status'), :class => classes)
end
end