From a58053bf78987257ae16bc223a5ac9adf8babb71 Mon Sep 17 00:00:00 2001 From: Alex Reisner <alex@alexreisner.com> Date: Wed, 3 Nov 2010 21:44:31 -0400 Subject: [PATCH] Fix: Model.near(...).count raises exception. This fixes an incompatibility with the will_paginate gem. --- lib/geocoder.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/geocoder.rb b/lib/geocoder.rb index b38cf2e5..8c34517f 100644 --- a/lib/geocoder.rb +++ b/lib/geocoder.rb @@ -74,7 +74,6 @@ module Geocoder # http://www.scribd.com/doc/2569355/Geo-Distance-Search-with-MySQL # def full_near_scope_options(latitude, longitude, radius, options) - options[:order] ||= 'distance ASC' lat_attr = geocoder_options[:latitude] lon_attr = geocoder_options[:longitude] distance = "3956 * 2 * ASIN(SQRT(" + @@ -83,6 +82,7 @@ module Geocoder "COS(#{lat_attr} * PI() / 180) * " + "POWER(SIN((#{longitude} - #{lon_attr}) * " + "PI() / 180 / 2), 2) ))" + options[:order] ||= "#{distance} ASC" default_near_scope_options(latitude, longitude, radius, options).merge( :select => "#{options[:select] || '*'}, #{distance} AS distance", :having => "#{distance} <= #{radius}" -- GitLab