Skip to content


Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP


:required doesn't seem to work well on Boolean types #370

rtyler opened this Issue · 4 comments

5 participants


I'll come back later with a test case but the gist of it here is that a column:

   key :recurring, Boolean, :required => true

When saving that document which has foobar.recurring = false the following failure occurs:

 Validation failed: Recurring can't be blank (MongoMapper::DocumentNotValid)

Probably using #present? in the validation, which returns false for false.


Same here.


MongoMapper seems to work like ActiveRecord 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"

In my models I always use
validates_inclusion_of :some_boolean_key, :in => [true, false]
and it works fine.


Closed by 4c96d02.

@cheald cheald closed this
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.