Ignore unknown countries when doing geolocation
authorTom Hughes <tom@compton.nu>
Thu, 13 May 2010 14:32:46 +0000 (15:32 +0100)
committerTom Hughes <tom@compton.nu>
Thu, 13 May 2010 14:32:46 +0000 (15:32 +0100)
lib/osm.rb

index c92655a..704bc09 100644 (file)
@@ -471,9 +471,7 @@ module OSM
   def self.IPLocation(ip_address)
     code = OSM.IPToCountry(ip_address)
 
-    unless code.nil?
-      country = Country.find_by_code(code)
-
+    if code and country = Country.find_by_code(code)
       return { :minlon => country.min_lon, :minlat => country.min_lat, :maxlon => country.max_lon, :maxlat => country.max_lat }
     end