Can't you just call distinct on your scope with _id as an attribute?
red_duck_ids = Foo.where(color: 'red').distinct(:_id)
Which will return you a list of all _id
s that meet your conditions. You can find more information on Mongo's distinct
documentation.
You can also have a look at only
and if you are using version 3.1 or newer you can also use Criteria#pluck
.