Gem GeoKit:尝试初始化我自己的地理编码器时未初始化的常量GeoKit :: Geocoders :: Geocoder

时间:2014-06-24 02:25:20

标签: ruby-on-rails geokit

我按照安装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课程的任何建议,我们将不胜感激。

1 个答案:

答案 0 :(得分:6)

Geokit和GeoKit(大写K)工作了一段时间。 1.7.1删除了GeoKit。

只需用Geokit替换任何对GeoKit的引用

我是Geokit的维护者,所以如果有任何README已经过时(我看不到),请告诉我。