我正在玩Geocoder gem,我将此代码添加到用户模型
include GeoKit::Geocoders
geocoded_by :full_street_address # can also be an IP address
after_validation :geocode # auto-fetch coordinates
在另一个控制器中,在CarController#index我调用:
zip_code = '94301'
aaa = Geocoder.search(zip_code).first.coordinates
puts '==='
puts aaa.inspect
puts '==='
但不是
s[0].latitude # => 37.4457966
s[0].longitude # => -122.1575745
s[0].address # => "Palo Alto, CA 94301, USA"
我有
undefined method `search' for Geokit::Geocoders::Geocoder:Class
地理编码器的设置有什么问题?