Rails database defaults and model validation for boolean fields

From here

If you want to validate the presence of a boolean field (where the
real values are true and false), you will want to use
validates_inclusion_of :field_name, :in => [true, false] This is due
to the way Object#blank? handles boolean values. false.blank? # =>
true

Or in Rails3 way

validates :field, :inclusion => {:in => [true, false]}

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)