Module ActionView::Helpers::ActiveRecordHelper
In: lib/localization_simplified.rb

Modify ActiveRecord to use error message headers (text from lang-file)

Methods

External Aliases

error_messages_for -> old_error_messages_for

Public Instance methods

[Source]

    # File lib/localization_simplified.rb, line 65
65:       def error_messages_for(object_name, options = {})
66:         messages = ActiveRecord::Errors.default_error_messages
67:         options = options.symbolize_keys
68:         object = instance_variable_get("@#{object_name}")
69:         if object && !object.errors.empty?
70:           content_tag("div",
71:             content_tag(
72:               options[:header_tag] || "h2",
73:               format( messages[:error_header], pluralize(object.errors.count, messages[:error_translation]), object_name.to_s.gsub("_", " ")  )
74:               #"#{pluralize(object.errors.count, "error")} prohibited this #{object_name.to_s.gsub("_", " ")} from being saved"
75:             ) +
76:             content_tag("p", messages[:error_subheader]) +
77:             content_tag("ul", object.errors.full_messages.collect { |msg| content_tag("li", msg) }),
78:             "id" => options[:id] || "errorExplanation", "class" => options[:class] || "errorExplanation"
79:           )
80:         else
81:           ""
82:         end
83:       end

[Validate]