I'm using Geokit. I have the following in my model:
# Distance-based finder method
# Usage:
# - find_this_within(Shop.first, 10)
def self.find_this_within(origin, within)
if origin.geocoded?
find(:all, :origin => origin, :within => within )
else
[]
end
end
Then in my controller:
@shops = s.paginate(:page => params[:page], :per_page => 20)
Currently the output is listed in ID ascending. I want it to sort from nearest to furthest. What should I do?
Thanks.