rails3 customized error message

In rails3 this is what I get.

validates_presence_of :subject #=> subject can't be blank

validates_presence_of :subject, :message => "can't be empty" #=> subject can't be empty

However What I want is #=> Please enter title even though the field name is "subject".

How do I do that in rails3?

Try this:

I haven't played around with it, but object.errors[attribute] << error_message should probably be changed to just error_message.

Let me know how it goes.

-sunny http://ezror.com

validates :subject , :presence => “Greetings sire, please introduce the title!”

am not sure if you need to put { }