error in request.location ruby geocoder

梦想的初衷 提交于 2019-12-04 12:12:15

I have found the issue, it was that the search IP was taking too much time, so I created an initializer and changed the default timeout

config/initializer/geocoder.rb

Geocoder.configure(
 :timeout => 20
)

How I found

I open the rails c and search my IP

$ location = Geocoder.search("myIpAddres")
Geocoding API not responding fast enough (use Geocoder.configure(:timeout => ...) to set limit).
=> []

Now it works

$ location = Geocoder.search("myIpAddres")
=> [#<Geocoder::Result::Freegeoip:0xa7130b8 @data={"ip"=>"myIpAddres", "country_code"=>"CO", "country_name"=>"Colombia", "region_code"=>"02", "region_name"=>"Antioquia", "city"=>"Medellín", "zipcode"=>"", "latitude"=>6.2518, "longitude"=>-75.5636, "metro_code"=>"", "areacode"=>""}, @cache_hit=nil>]
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!