Module: FormErrors::ViewHelpers

Included in:
FormErrors
Defined in:
lib/form_errors/view_helpers.rb

Instance Method Summary collapse

Instance Method Details

#bass_display_errors(object, error_string = nil, html = {}) ⇒ Object



22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
# File 'lib/form_errors/view_helpers.rb', line 22

def bass_display_errors(object, error_string = nil, html = {})
  return unless object && object.errors.any?

  <<-HTML
    <div class="bold p2 white bg-red">
      <h2 class="#{ html[:error_string_class] }">
        #{ get_error_string(error_string, object) }
      </h2>
      <ul class="#{ html[:error_list_class] }">
        #{ object.errors.full_messages.map do |msg|
             "<li class=\"#{ html[:error_list_item_class] }\">#{ msg }</li>"
           end.join }
      </ul>
    </div>
  HTML
  .html_safe
end

#display_errors(object, error_string = nil, html = {}) ⇒ Object



3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
# File 'lib/form_errors/view_helpers.rb', line 3

def display_errors(object, error_string = nil, html = {})
  return unless object && object.errors.any?

  <<-HTML
    <div class="alert alert-danger alert-dismissable">
      <button type="button" class="close" data-dismiss="alert" aria-hidden="true">&times;</button>
      <h2 class="#{ html[:error_string_class] }">
        #{ get_error_string(error_string, object) }
      </h2>
      <ul class="#{ html[:error_list_class] }">
        #{ object.errors.full_messages.map do |msg|
             "<li class=\"#{ html[:error_list_item_class] }\">#{ msg }</li>"
           end.join }
      </ul>
    </div>
  HTML
  .html_safe
end