地理编码API的响应无效JSON.和request.location = nil

She*_*ary 7 ruby ruby-on-rails geocode

if Rails.env.development?
      @current_location_geo = Geocoder.search(request.remote_ip).first
    else
      @current_location_geo = request.location
    end
    if !@current_location_geo.nil? && @current_location_geo.ip == "127.0.0.1"
      @departure_currency_code= "AUD"
      @departure_currency_name= ["Australian Dollar(AUD $)","AUD"]
    else
      @country = Country.new(request.location.data["country_code"].to_s)
      @country_code = @country.currency.code
    end
end
Run Code Online (Sandbox Code Playgroud)

我收到了request.location nil.我试图在配置中添加超时但它对我没有帮助.

生产模式中的错误,因为"地理编码API的响应无效JSON".

当我追踪它时,我得到request.location为零.

我的地理编码器版本是(1.2.6).

neo*_*ate 1

配置/初始化器/geocoder.rb

Geocoder.configure(
 timeout: 10,
 ip_lookup: :telize   
)
Run Code Online (Sandbox Code Playgroud)

来源: https: //github.com/alexreisner/geocoder/issues/777