【发布时间】:2016-10-20 07:31:56
【问题描述】:
我有一个带有users 表的Ruby on Rails 项目,我需要存储来自用户输入的location_id。
如果用户输入
Buckingham Palace,那么location_id 应该是london_id如果用户输入
Wall Street,那么location_id 应该是new_york_id如果用户输入
Statue of Liberty,那么location_id 应该是new_york_id如果用户键入
United States,则 location_id 应为nil
我正在使用geocoder gem,但我无法检索城市 ID。例如:
Geocoder.search("London").first.place_id # => ChIJdd4hrwug2EcRmSrV3Vo6llI
Geocoder.search("Buckingham Palace").first.place_id # => ChIJtV5bzSAFdkgRpwLZFPWrJgo
我需要两者都是 ChIJdd4hrwug2EcRmSrV3Vo6llI(伦敦 ID)
【问题讨论】:
-
你在使用geocoder gem吗?
-
是的,如问题中所述
标签: ruby-on-rails ruby geocoding geocode rails-geocoder