我按照安装 geokit-rails (v 2.0.1) 和 geokit (v 1.8.5) 的说明进行操作。然后尝试创建我自己的地理编码器(用于测试)。这是我在 config/initializers/fake_geocoder.rb 文件中使用的代码
require 'geokit'
module GeoKit
module Geocoders
class FakeGeocoder < Geocoder
#to use, include :fake in the list of geocoders
private
def self.do_geocode(location, options = {})
geocode_payload = GeoKit::GeoLoc.new(:lat => 123.456, :lng => 123.456)
geocode_payload.success = true
return geocode_payload
end
end
end
end
尝试启动 rails 控制台(bundle exec rails c)时,出现以下错误:
../config/initializers/fake_geocoder.rb:6:in `<module:Geocoders>': uninitialized constant GeoKit::Geocoders::Geocoder (NameError)
from ../config/initializers/fake_geocoder.rb:5:in `<module:GeoKit>'
from ../config/initializers/fake_geocoder.rb:4:in `<top (required)>'
您可以就为什么找不到 Geocoder 类提供的任何建议将不胜感激。