Отказ в соединении Ruby Geocoder
Когда я ищу IP-адрес, я получаю следующую ошибку:
pry(main)> Geocoder.search("130.132.173.68")
Geocoding API connection refused.
=> []
Если я ищу что-нибудь еще, например.
pry(main)> Geocoder.search("new haven")
Я получаю правильные результаты. Есть ли проблема с сервисом freegeoip?
1 ответ
Убедитесь, что у вас есть настройка инициализатора для Geocoder со всеми настройками конфигурации. Это была проблема для меня. Что-то вроде этого:
# config / initializers / geocoder.rb
Geocoder.configure(
# geocoding options
:timeout => 7, # geocoding service timeout (secs)
:lookup => :google, # name of geocoding service (symbol)
:language => :en, # ISO-639 language code
:use_https => true, # use HTTPS for lookup requests? (if supported)
:http_proxy => '', # HTTP proxy server (user:pass@host:port)
:https_proxy => '', # HTTPS proxy server (user:pass@host:port)
:api_key => nil, # API key for geocoding service
:cache => nil, # cache object (must respond to #[], #[]=, and #keys)
:cache_prefix => "geocoder:", # prefix (string) to use for all cache keys
# IP address geocoding service (see below for supported options):
#:ip_lookup => :maxmind,
# to use an API key:
#:api_key => "...",
# exceptions that should not be rescued by default
# (if you want to implement custom error handling);
# supports SocketError and TimeoutError
# :always_raise => [],
# calculation options
# :units => :mi, # :km for kilometers or :mi for miles
# :distances => :linear # :spherical or :linear
)