mongoid/mongoid — Issue #1766: Don't hit db when relation key field is blank
Author: bensymonds
Created: 2012-02-27 15:31:29+00:00
State: open

E.g:

```ruby
class Foo; include Mongoid::Document; has_and_belongs_to_many :bars;end
class Bar; include Mongoid::Document; end
f = Foo.create!
f.bar_ids
=> []
f.bars
=> []
```

All good, but in the log for the last command I see:

```
MONGODB blah_development['bars'].find({:_id=>{"$in"=>[]}})
```

Could just save the db hit by noticing `bar_ids` is empty..?