From adba1b5c3f7f80873fd60c566514331e0fb6b9a7 Mon Sep 17 00:00:00 2001
From: dbloete <mail@dennisreimann.de>
Date: Wed, 26 Oct 2011 11:22:39 +0200
Subject: [PATCH] Allow for bounds to be nil or already flattened

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

diff --git a/lib/geocoder/stores/active_record.rb b/lib/geocoder/stores/active_record.rb
index bbcce73b..2a9076ce 100644
--- a/lib/geocoder/stores/active_record.rb
+++ b/lib/geocoder/stores/active_record.rb
@@ -48,9 +48,8 @@ module Geocoder::Store
         # (<tt>[[sw_lat, sw_lon], [ne_lat, ne_lon]]</tt>).
         #
         scope :within_bounding_box, lambda{ |bounds|
-          sw_lat, sw_lng, ne_lat, ne_lng = bounds.flatten!
+          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 << if sw_lng > ne_lng   # Handle a box that spans 180
             "longitude BETWEEN #{sw_lng} AND 180 OR longitude BETWEEN #{ne_lng} and -180"
-- 
GitLab