Module: FormErrorsHelper
- Defined in:
- app/helpers/form_errors_helper.rb
Instance Method Summary collapse
Instance Method Details
#error_details ⇒ Object
38 39 40 41 42 43 44 45 46 |
# File 'app/helpers/form_errors_helper.rb', line 38 def error_details return unless object.respond_to?(:errors) && object.errors.any? = object.errors..map { |msg| @template.content_tag(:li, msg) }.join @template.content_tag :ul, class: 'my-0' do .html_safe end end |
#error_messages_for(attribute) ⇒ Object
25 26 27 28 29 30 31 32 33 34 |
# File 'app/helpers/form_errors_helper.rb', line 25 def (attribute) return unless object.respond_to?(:errors) && object.errors.any? = object.errors[attribute] @template.content_tag :div, class: 'alert alert-danger' do @template.fa_icon_tag('remove') + ' ' + .map { || object.errors.(attribute, ) }.to_sentence end end |
#error_notification ⇒ Object
3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 |
# File 'app/helpers/form_errors_helper.rb', line 3 def error_notification return unless object.respond_to?(:errors) && object.errors.any? error_count = object.errors.count humanized_name = I18n.t("activerecord.models.#{object_name.to_s.downcase}.one", default: object_name.to_s.humanize) = "#{@template.pluralize(error_count, 'errors')} prohibited this #{humanized_name} from being saved." = I18n.t('activerecord.errors.template.header', count: error_count, model: humanized_name, default: ) @template.content_tag :div, class: 'alert alert-danger' do @template.fa_icon_tag('remove') + ' ' + + error_details end end |