lib/ahoy/model.rb in ahoy_matey-0.1.1 vs lib/ahoy/model.rb in ahoy_matey-0.1.2
- old
+ new
@@ -73,10 +73,17 @@
true
end
def set_location
if respond_to?(:ip) and [:country=, :region=, :city=].any?{|method| respond_to?(method) }
- location = Geocoder.search(ip).first rescue nil
+ location =
+ begin
+ Geocoder.search(ip).first
+ rescue => e
+ $stderr.puts e.message
+ nil
+ end
+
if location
self.country = location.country.presence if respond_to?(:country=)
self.region = location.state.presence if respond_to?(:region=)
self.city = location.city.presence if respond_to?(:city=)
end