使用Geocoder gem,使用高级地理编码部分,我似乎无法让它工作。我基本上把谷歌地图文档上的每个地址组件类型都放在了Geocoder::Result 块中:
geocoded_by :street_address do |obj,results|
if geo = results.first
obj.route = geo.route
obj.intersection = geo.intersection
obj.political = geo.political
obj.country = geo.country
obj.administrative_area_level_1 = geo.administrative_area_level_1
obj.administrative_area_level_2 = geo.administrative_area_level_2
obj.administrative_area_level_3 = geo.administrative_area_level_3
obj.colloquial_area = geo.colloquial_area
obj.floor = geo.floor
obj.room = geo.room
end
end
after_validation :reverse_geocode
但我得到这个错误:
NoMethodError in StoresController#create
undefined method `route' for #<Geocoder::Result::Google:0x6939150>
如果我删除它这个对象,它只会转到下一个对象,例如intersection
.
这里有什么问题?