Fully custom validation error message with Rails
Posted
by marcgg
on Stack Overflow
See other posts from Stack Overflow
or by marcgg
Published on 2009-04-30T19:05:29Z
Indexed on
2010/06/14
10:12 UTC
Read the original article
Hit count: 266
ruby-on-rails
Using Rails I'm trying to get an error message like "The song field can't be empty" on save. Doing the following:
validates_presence_of :song_rep_xyz, :message => "can't be empty"
... only displays "Song Rep XYW can't be empty", which is not good because the title of the field is not user friendly. How can I change the title of the field itself ? I could change the actual name of the field in the database, but I have multiple "song" fields and I do need to have specific field names.
I don't want to hack around rails' validation process and I feel there should be a way of fixing that.
© Stack Overflow or respective owner