Module: ActsAsGeocodable::RemoteLocation
- Defined in:
- lib/acts_as_geocodable/remote_location.rb
Instance Method Summary collapse
-
#remote_location ⇒ Object
Get the remote location of the request IP using hostip.info.
Instance Method Details
#remote_location ⇒ Object
Get the remote location of the request IP using hostip.info
6 7 8 9 10 11 12 13 14 15 16 |
# 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 |