ryanong / mongoid_spacial

A Mongoid Extention that simplifies and adds support for MongoDB Geo Spacial Calculations.
MIT License
138 stars 63 forks source link

geo_near Sorting #21

Closed rdetert closed 12 years ago

rdetert commented 12 years ago

Am I doing something wrong? It seems that I geo_near automatically always sorts by distance. I'd like to be able to sort by other fields:

@appointments = Appointment.desc(:created_at).geo_near(mycity.coords, :max_distance => @distance, :unit => :mi, :spherical => true)

This always sorts by distance, not created_at

ryanong commented 12 years ago

You are using the wrong method.

GeoNear will always sort by distance.

River.where(:source.near => {:point => [-73.98, 40.77], :max => 5})

is the filter