I’m creating a Rails app, and I have a model called User. In this model I have a boolean value called isagirl. A user must specify if it is a girl or not, which is done by two radio buttons. In my model I have this:
validates_presence_of :isagirl, :message => "You must be either a Boy or a Girl. If not, please contact us."
However, when I don’t specify a sex, I’m seeing this:
Isagirl You must be either a Boy or a Girl.
as an error message. The problem is that ‘Isagirl’ must not be there in the error message. How can I disable that? And no, using CSS to hide it is no option.
Thanks
The way that I do this is to output the message without the field name. For example, I have a partial that outputs the error messages after validation fails.
Notice that this does not output the attribute. You just need to make sure that all your messages makes sense without an attribute name.