Custom error messages

On a model I have the following simple validator:

def validate
unless name && name =~ /^\w+$/
errors.add_to_base(“Name is missing”)
end
end

I would like to display a custom message on my views, without using the
helper <%= error_messages_for “table” %>

Where the messages from errors.add_to_base are stored and how to access
them in the views?

Fernando,

Where the messages from errors.add_to_base are stored and how to access
them in the views?
ActiveRecord stores them in an array. There are several ways you can
get to these for example object.errors.full_messages will return an
array of the full error messages. You may also want to read the
following page from the API
http://api.rubyonrails.org/classes/ActiveRecord/Errors.html


Joe C.