No one was able to answer Rich Collins's question:

I would like to display the full error message for some errors, but only the :message component for others. Is there any way to specify this?

<%= errors_messages_for 'foo' %>

validates_presence_of :bar, :message => 'Bad Bar!'
validates_presence_of :foo, :message => 'is missing'

Should output:

There were problems with the following fields:
Bad Bar!
Foo is missing

People succeed in answering Rich Collins's questions 37% of the time (32 successes in 86 attempts).

Answers by: Jake McArthur

Jake McArthur's Answer:

Reply by Jake McArthur 853 days ago

Well, there are probably many ways to go about doing this, but here is the most painless way I can think of right now. Stick something like this wherever you think it belongs and then whenever the message contains the name of the attribute already, it will not be appended to the beginning when it is output:

module ActiveRecord

class Errors
def full_messages
full_messages = []
@errors.each_key do |attr|
@errors[attr].each do |msg|
next if msg.nil?
if attr == "base" || msg.include? @base.class.human_attribute_name(attr)
full_messages << msg
else
full_messages << @base.class.human_attribute_name(attr) + " " + msg
end
end
end
return full_messages
end
end
end

Like I said, there may be a cleaner or more flexible way, but this seems to fit the bill just based your example.

Reply by Rich Collins 853 days ago

Ah I was hoping for something builtin. Some more configuration when you add the errors would be nice. I talked to some other people and it looks like it is not possible.

I am going to close this one out but thanks for your response!