Validation + should be > 0


#1

Hi,

my default value for variable mainimage_id is 0. I am trying to apply
really basic validation. If mainimage_id is 0 it should fail and if it
is > 0 it should pass the validation.

validates_numericality_of :mainimage_id, :greater_than => 1, :message =>
“Choose image.”

This will pass the validation even if the value is 0.
Thanks for your help.

P.


#2

You could try making the default value nil. Makes more sense anyway -
nil indicates lack of data, while 0 suggests there is a default image.

On Thu, Feb 26, 2009 at 12:07 PM, Petan C.