module ErrorsHelper def simple_error(field, error_msg) {"errors" => {field => [error_msg]}} end def errors_for(object) if object.errors.any? content_tag(:div, class: 'card text-white bg-danger mb-3') do concat(content_tag(:div, class: 'card-header') do concat(content_tag(:h4) do concat "The form contains #{pluralize(object.errors.count, 'error')}:" end) end) concat(content_tag(:div, class: 'card-body') do concat(content_tag(:ul) do object.errors.full_messages.each do |msg| concat content_tag(:li, msg) end end) end) end end end end