Rails VALIDATES w :message ?


I have the following:

      validates :fname, :presence => true, :length => { :minimum => 2 }

How do I add a message to that? Right now the errors says "Fname is too short (minimum is 2 characters)" I'd like it to say First Name and not Fname.


You can simply change the name of the field in your locale file:

en:   activerecord:     attributes:       user:         fname: First name

Check out the Rails Internationalization Guide for more info:

that is awesome . thank you!

Or, by doing a search of the forum, you'd find my question of the same subject recently:

short answer:

   validates :name, :presence => { :message => "an alternate message" }