Is it possible to change the attribute name displayed to the user via
the error_messages_for tag? For example if you wanted to use 'email'
as an attribute name and db column but 'e-mail' as the attribute name
displayed on the webpage. I'm thinking of using the Custom Error
Message plugin (http://wiki.rubyonrails.org/rails/pages/Custom+Error
+Message) but you have to rewrite the whole error message.
Any better ideas?
I was hoping for a slightly more elegant solution that doesn't require
monkey patching. Also the code states that human_attribute is
deprecated:
# Transforms attribute key names into a more humane format, such
as "First name" instead of "first_name". Example:
# Person.human_attribute_name("first_name") # => "First name"
# Deprecated in favor of just calling "first_name".humanize
def human_attribute_name(attribute_key_name) #:nodoc:
attribute_key_name.humanize
end
Thanks for the reply. Any other ideas? I think using the custom error
message plugin might be the best option.
Eric