Module: FormErrors::ViewHelpers

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

Instance Method Summary collapse

Instance Method Details

#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?

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