Jeroen Houben wrote:> Hi,
>
> I know how I can change individual error messages (per model property so
> to say), but a header message is always prepended. It looks like:
> "# errors prevented you from saving the Model"
>
> I can''t spot where I would change this particular piece of text..
Hmm. Looking at the source, it seems like it''s hardcoded.
# File
vendor/rails/actionpack/lib/action_view/helpers/active_record_helper.rb,
line 99
99: def error_messages_for(object_name, options = {})
100: options = options.symbolize_keys
101: object = instance_variable_get("@#{object_name}")
102: unless object.errors.empty?
103: content_tag("div",
104: content_tag(
105: options[:header_tag] || "h2",
106: "#{pluralize(object.errors.count, "error")}
prohibited this #{object_name.to_s.gsub("_", " ")} from
being saved"
107: ) +
108: content_tag("p", "There were problems with the
following fields:") +
109: content_tag("ul", object.errors.full_messages.collect
{
|msg| content_tag("li", msg) }),
110: "id" => options[:id] ||
"errorExplanation", "class" =>
options[:class] || "errorExplanation"
111: )
112: end
113: end