From e6f56621ea3ee0fb5ef67993f2f893bf535e65e8 Mon Sep 17 00:00:00 2001
From: kongo <d.parshenko@gmail.com>
Date: Sat, 14 Jan 2012 10:30:15 +0200
Subject: [PATCH] within_bounding_box scope takes field names from options

---
 lib/geocoder/stores/active_record.rb | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/lib/geocoder/stores/active_record.rb b/lib/geocoder/stores/active_record.rb
index 344979e9..819e987c 100644
--- a/lib/geocoder/stores/active_record.rb
+++ b/lib/geocoder/stores/active_record.rb
@@ -50,11 +50,11 @@ module Geocoder::Store
         scope :within_bounding_box, lambda{ |bounds|
           sw_lat, sw_lng, ne_lat, ne_lng = bounds.flatten if bounds
           return where(:id => false) unless sw_lat && sw_lng && ne_lat && ne_lng
-          spans = "latitude BETWEEN #{sw_lat} AND #{ne_lat} AND "
+          spans = "#{geocoder_options[:latitude]} BETWEEN #{sw_lat} AND #{ne_lat} AND "
           spans << if sw_lng > ne_lng   # Handle a box that spans 180
-            "longitude BETWEEN #{sw_lng} AND 180 OR longitude BETWEEN -180 AND #{ne_lng}"
+            "#{geocoder_options[:longitude]} BETWEEN #{sw_lng} AND 180 OR #{geocoder_options[:longitude]} BETWEEN -180 AND #{ne_lng}"
           else
-            "longitude BETWEEN #{sw_lng} AND #{ne_lng}"
+            "#{geocoder_options[:longitude]} BETWEEN #{sw_lng} AND #{ne_lng}"
           end
           { :conditions => spans }
         }
-- 
GitLab