【发布时间】:2016-04-09 21:26:42
【问题描述】:
我正在使用 Geocoder gem,但最近它似乎不起作用。
我收到此错误:
Geocoding API not responding fast enough (use Geocoder.configure(:timeout => ...) to set limit).
我的 application_controller.rb 是:
before_filter :lookup_ip_location
private
def lookup_ip_location
if Rails.env.development?
prr = Geocoder.search(request.remote_ip).first
p "this is #{prr.inspect}"
else
request.location
end
end
这是 development.rb:
# test geocoder gem locally
class ActionDispatch::Request
def remote_ip
"71.212.123.5" # ipd home (Denver,CO or Renton,WA)
# "208.87.35.103" # websiteuk.com -- Nassau, Bahamas
# "50.78.167.161" # HOL Seattle, WA
end
end
我正在从 development.rb 加载 IP 地址以检查地理编码器是否在本地工作,但它不能。我收到上述错误。
另外,当打印 prr 时,我得到了 nil。
我还添加了一个 geocoder.rb 初始化程序,将超时时间提高到 15 秒,但即使在浏览器加载页面 15 秒后,我仍然收到相同的消息。
它坏了吗?我应该使用其他宝石吗?如果有,您有什么建议吗?
【问题讨论】:
标签: ruby-on-rails ruby rails-geocoder