Method: Sufia::SufiaHelperBehavior#error_messages_for

Defined in:
app/helpers/sufia/sufia_helper_behavior.rb

#error_messages_for(object) ⇒ Object



16
17
18
19
20
21
22
23
24
25
26
27
28
29
# File 'app/helpers/sufia/sufia_helper_behavior.rb', line 16

def error_messages_for(object)
  if object.try(:errors) and object.errors.full_messages.any?
    (:div, class: 'alert alert-block alert-error validation-errors') do
      (:h4, I18n.t('sufia.errors.header', model: object.class.model_name.human.downcase), class: 'alert-heading') +
        (:ul) do
          object.errors.full_messages.map do |message|
            (:li, message)
          end.join('').html_safe
        end
    end
  else
    '' # return empty string
  end
end