0

Following query is running in MongoDB console correctly,

> db.venues.find({'location.region_id':ObjectId("533e67246d696e1279170000")}).count()
8

But when i write the same query in rails using mongoid its not showing anything, the query is as follows,

<%= Venue.where({'location.region_id' => '533e67246d696e1279170000'}).count %>

I don't know what's wrong with my query.

RubyOnRails
  • 235
  • 1
  • 15

1 Answers1

1

Convert the id to an ObjectId object:

<%= Venue.where({'location.region_id' => BSON::ObjectId.from_string('533e67246d696e1279170000')}).count %>
Gergo Erdosi
  • 40,904
  • 21
  • 118
  • 94