1
我为我的Ruby on Rails项目安装了GeoCoder gem,并试图获得城市的邮政编码,但postal_code
始终为零。我输入的所有城市如加利福尼亚州的圣何塞和西雅图都产生了postal_code
的零。如何使用Ruby on Rails中的Geocoder gem获得postal_code?
我在我的轨道控制台中运行这些查询示例:
Geocoder.search("San Jose, CA").first.postal_code
一种解决方法,我发现是运行下面的,但它使2调用这违背了服务配额:
Geocoder.search(Geocoder.search("Seattle, WA").first.coordinates).first.postal_code
有没有更好的语法来做到这一点?
谢谢!
可能重复[红宝石地理编码宝石找到邮政编码(http://stackoverflow.com/questions/8935011/ruby-geocoder-gem-to -find-邮政代码) –