Open jmeiss opened 14 years ago
There is no distance attribute anymore, checkout the by_distance method in the code, might help you out a bit. I had similar problems when upgrading the geokit / geokit-rails version.
I got this problem too with geokit-rails 2.0.1. Why did they remove that field??
I also want to use the following query as described in the Readme docu, but it does not work:
Location.within(5, :origin => @somewhere).order('distance DESC, nbr_seats ASC')
In #39 and #54 is suggested to use sort_by on a DistanceCollection but this way the queries are not chainable anymore (e.g. for paging). by_distance isn't an alternative either because it does not allow to limit the radius anymore.
Any ideas how to solve this? At least the Readme should be updated...
Finally I used the following workaround to solve the problem:
distance_column_name = distance_sql(normalize_point_to_lat_lng(origin), default_units, default_formula)
within(within, :origin => origin).order("#{distance_column_name} ASC")
At last I found the patch in #56 which works perfectly!
I've tryed to order my request by distance but I get an exception:
I've well added this lines to my User model: acts_as_mappable :distance_field_name => :distance, :lat_column_name => :latitude, :lng_column_name => :longitude
And this is my AR query:
I'me using rails3, with pgsql.
Thank you very much for you work!!! :)