module ActsAsGeocodable::RemoteLocation
Public Instance Methods
remote_location()
click to toggle source
Get the remote location of the request IP using hostip.info
# File lib/acts_as_geocodable/remote_location.rb, line 6 def remote_location if request.remote_ip == "127.0.0.1" # otherwise people would complain that it doesn't work Graticule::Location.new(locality: "localhost") else Graticule.service(:host_ip).new.locate(request.remote_ip) end rescue Graticule::Error => error logger.warn "An error occurred while looking up the location of '#{request.remote_ip}': #{error.message}" nil end