Select helper :prompt storing 0 in database

Can't use a validation in your controller for this field?

Gah, of course I mean "model" there, not "controller".

<nod> Still, that shouldn't be too difficult, right?

def validate
  if self.whatever == 0
    ...

Michael Campbell wrote:
>> seen in other areas) is that Ruby coerces nil or blank strings ("") to
>> 0. The standard validator, for example, validates_numericality_of, will
>> let a 0 (zero) go through just fine.
>
> <nod> Still, that shouldn't be too difficult, right?
>
> def validate
> if self.whatever == 0
> ...

True. Guess that's what we will do - seems cleaner than trapping things
in the controller the way we have been , although still seems a bit
clunky....

I'm still not completely comfortable with validations in the model; no
reason for that, just my MVC upbringing that always did that sort of
thing in the controller. I'm getting used to it though.

Anyway, thanks for the assist.

Glad I could help!