2016-04-04 21:25:38 -04:00
|
|
|
module FormHelper
|
|
|
|
def form_errors(model)
|
|
|
|
return unless model.errors.any?
|
|
|
|
|
|
|
|
pluralized = 'error'.pluralize(model.errors.count)
|
|
|
|
headline = "The form contains the following #{pluralized}:"
|
|
|
|
|
|
|
|
content_tag(:div, class: 'alert alert-danger', id: 'error_explanation') do
|
|
|
|
content_tag(:h4, headline) <<
|
2016-12-15 17:14:20 -05:00
|
|
|
content_tag(:ul) do
|
|
|
|
model.errors.full_messages.
|
|
|
|
map { |msg| content_tag(:li, msg) }.
|
|
|
|
join.
|
|
|
|
html_safe
|
|
|
|
end
|
2016-04-04 21:25:38 -04:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|