我正试图在我的应用程序中获得更低的github回购
https://github.com/mtodd/geoip我试着把它加起来
gem "geoip", :git => "git://github.com/mtodd/geoip.git"误差=
Could not find gem 'geoip (>= 0) ruby' in git://github.com/mtodd/geoip.git (at master).
Source does not contain any versions of 'geoip (>= 0) ruby'是否有与最新的GeoIP兼容的GEOIP的红宝石包装器?已经搜索了很长时间了,上面的那个似乎与1.4.7及更高版本兼容,但我无法安装它,还有其他建议吗?太棒了!
发布于 2012-03-07 16:16:39
我的个人档案里有这个:
gem "geoip-c", '~> 0.7.1', :git => "git://github.com/mtodd/geoip.git"据我所知,它完全兼容。
发布于 2014-05-09 20:27:29
我知道这是几年前发布的,但最近我很难找到一个好的最新宝石。我发现的是Geoip2 by YotpoLtd。
在我的Gemfile中
gem 'geoip2'Setting/Configuring
Geoip2.configure do |conf|
# Mandatory
conf.license_key = 'Your MaxMind License Key'
conf.user_id = 'Your MaxMind User Id'
# Optional
conf.host = 'geoip.maxmind.com' # Or any host that you would like to work with
conf.base_path = '/geoip/v2.0' # Or any other version of this API
conf.parallel_requests = 5 # Or any other amount of parallel requests that you would like to use
end使用的
data = Geoip2.omni('0.0.0.0') #this call is synchronous*注:我相信您可以将“omni”替换为产品级的名称:城市、国家等。
如果有错误,返回的散列将有一个错误对象,所以只需检查它是否存在。
if data.error
# error handling
else #still might want to check for data's existence ( if data )
#access object as you will
data.city.names.en
data.postal.code
end有关返回哈希的更多信息,请参见MaxMind网络服务文档。
https://stackoverflow.com/questions/9604775
复制相似问题