Steps to reproduce:
class Venue
field :coordinates, type: Array
index({coordinates: '2d'}, {min: -180, max: 180})
end
Have ran rake db:mongoid:create_indexes
Tried calling:
Venue.geo_near([@lat, @long])
And got:
Moped::Errors::OperationFailure:
The operation: #<Moped::Protocol::Command
@length=135
@request_id=3
@response_to=0
@op_code=2004
@flags=[]
@full_collection_name="encore_backend_test.$cmd"
@skip=0
@limit=-1
@selector={:geoNear=>"venues", :near=>[43.670906, -79.393331], :query=>{}, :spherical=>true}
@fields=nil>
failed with error "no geo index :("
Any suggestions?
Stupid mistake, forgot to do rake db:mongoid:create_indexes
with RAILS_ENV=test
for RSpec
Complete command
bundle exec rake db:mongoid:create_indexes RAILS_ENV=test
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With