Welcome to mirror list, hosted at ThFree Co, Russian Federation.

form_helper.rb « helpers « app - gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 913db3a3e26e9143492528329ac15e3480455520 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
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) <<
        content_tag(:ul) do
          model.errors.full_messages
            .map { |msg| content_tag(:li, msg) }
            .join
            .html_safe
        end
    end
  end
end