Skip to content
Snippets Groups Projects
Commit a58053bf authored by Alex Reisner's avatar Alex Reisner
Browse files

Fix: Model.near(...).count raises exception.

This fixes an incompatibility with the will_paginate gem.
parent f55060a1
No related branches found
No related tags found
No related merge requests found
......@@ -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}"
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment