How to handle error message when condition break both presence and numerical validation?

Hi all,

I have one numeric field “age” and it have two validation presence and
numerical true.
When i click submit without filling any value then i face error message
is
“is not number” ,but error message should be “is should be presence”.
How
to set this message?
Both the condition are satisfying.

Did i have to configure en.yml ?

Thanks

Fahim

  1. Why do you have two presence validators?
  2. add allow_blank: true to the numerical validator.


Dheeraj K.

Thanks for reply
Let me try this, then i will reply you updated .

Fahim

No, your not getting my question , actually i want presence and numeric
validation on “Age” field.
When i click submit without filling any value then i face error message
is
“is not number” ,but error message should be “is should be presence”.
How
to set this message?

Hope you understood issue.

Thanks
It works…

Best Regards
Fahim

On Wednesday, January 16, 2013 1:40:38 PM UTC+5:30, Ruby-Forum.com User

Try giving the following.

validates :age, :numericality => true, :allow_nil => true

This validation will not be invoked if the age is not present.