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.

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.

Try giving the following.

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

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

Thanks It works…

Best Regards Fahim