Custom errors for validates_presence, etc

I am trying to figure out how to customize the error messages when I use
validates_presence_of. I am validating a user name and I use <%=
error_messages_for ‘user’ %> in my view to display the messages. I know
you can customize in the model with :message =>‘custom message’, but I
am trying to get rid of the first part of the error message which is,

1 error prohibited this user from being saved
There were problems with the following fields:

Is there any way to do this or is it hard coded into the rails code?

I’m struggling with the same right now.
Does anybody know how to do this?
Thanks.

Sabon

On 6/9/07, Yanni M. [email protected] wrote:

Is there any way to do this or is it hard coded into the rails code?
The basic idea is to look at the source for error_messages_for and
then drop your own replacement into app/helpers/application_helper.rb.

Here’s a real simple example:

def error_messages_for(object_name)
object = instance_variable_get(“@#{object_name}”)
return ‘’ if object.errors.empty?
content_tag(‘ul’, object.errors.full_messages.collect {|msg|
content_tag(‘li’, msg)},
{ :class => ‘error’ })
end