I try to use postgis in rails and write my first request. I would like have : - the nearest points of another point (but without this point) - the name and the distance between the both
In my model I have write this scope :
scope :close_to, -> (latitude, longitude, distance_in_m = 1) {
where(%{
ST_Distance(lonlat, 'POINT(%f %f)') < %d
} % [longitude, latitude, distance_in_m * 1000])
}
How can I get the distance ?