So I was implementing validation rules on a model the other day,
and the model started acting really weird afterward :(
Sometimes it'll save the object, most of the time it wont.
After a few attempts to locate the problem, I noticed
an object can be saved if the boolean attribute
is set to true, but won't save if it's set to false.
turns out this is what's causing all the troubles
validates_presence_of
don't use validate_presence_of to evaluate any boolean or numeric type variables,
because if you a value of 0, it'll be treated as nil
instead, this is what I changed it to
validates_inclusion_of attributes, :in => [true, false]
and life is wonderful once again
J
Tuesday, November 6, 2007
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment