-
Notifications
You must be signed in to change notification settings - Fork 245
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
distance_by method is not working correctly #125
Comments
+1 |
Can confirm this is an issue for me as well. The SQL that is generated in for my use case (in postgres) is:
Looking under the hood, Postgres ignores the distance based ordering. If I add it to the select query as a virtual column, like so:
I get the expected result. I'm using Postgres 9.6.5 and Rails 4.2 BTW. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
So, I'm using geokit-rails and I would like to sort by distance, specifically showing the nearest meals first and descending from there. e.g. 5km, 10km, 15km.
However, for some reason the distance_by method isn't working at all, and the distances are all over the place.
This is how we're using it:
all_venues = Venue.where( 'listed = ? AND packages_count > ?', true, 0 ).by_distance(origin: search_location).search(params[:search]) || Venue.where(listed: true).all
Are there any work around methods to use? Or how can I sort from nearest to furthest with geokit-rails?
Thanks!
The text was updated successfully, but these errors were encountered: