mongoid/mongoid — Issue #1590: Serialization Issues with true/false values in criteria
Author: chriseppstein
Created: 2012-01-12 22:57:54+00:00
State: open

In my fork, I had to add [this patch](https://github.com/chriseppstein/mongoid/commit/df055c6411ee1f344c83cd7aec294a6ce1ea536e) to fix the issue I was encountering:

```
test_it_can_return_enhanced_resources_in_a_location(Document::ResourceTest):
NoMethodError: undefined method `instantiate' for TrueClass:Class
app/models/document/resource.rb:246:in `block in '
test/unit/document/resource_test.rb:213:in `block in '
```

The relevant query in my code:

```ruby
named_scope(:enhanced_within, lambda {|enhanced_location|
where(:enhancements.matches => {
:region => enhanced_location.id,
:enhancement_level => {"$gt" => 0},
:service_area => {"$ne" => true}
})
})
```

The issue was with the `:service_area` constraint.

Also note that ` :service_area.ne => true` generated invalid output that was rejected by the mongo driver.

I am using the 2.2.x stable releases because we have not yet upgraded this app to rails 3.1 but I saw that there was no serialization added for TrueClass or FalseClass in master either. I feel like this is really basic functionality and so I'm confused how this can be broken -- I hope I am missing something obvious.