1

I followed the instructions on installing geokit-rails (v 2.0.1) and geokit (v 1.8.5). Then attempted to create my own geocoder (to be used with tests). Here is the code I use in my config/initializers/fake_geocoder.rb file

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

When attempting to start up the rails console (bundle exec rails c), I get the following error:

../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)>'

Any advice you can provide as to why it can't find the Geocoder class would be greatly appreciated.

Tom H
  • 207
  • 2
  • 13

1 Answers1

7

For a while Geokit and GeoKit (capital K) worked. 1.7.1 removed GeoKit.

Simply replace any reference to GeoKit with Geokit

I'm the maintainer of Geokit so if there's any README's that are out of date (I couldn't see any) please let me know.

Michael Noack
  • 356
  • 1
  • 5
  • Thank you Michael - I don't have the code with me now, but will make this change tonight and test it and will mark your answer accordingly. – Tom H Jun 24 '14 at 16:44
  • That did the trick. One small observance. Using the config settings in the README, I got the following error: undefined method `premium=' for Geokit::Geocoders::GeonamesGeocoder:Class. Commenting out that line allowed me to proceed. – Tom H Jun 25 '14 at 00:04
  • Wow. This saved me a ton of time! – rosem Mar 03 '18 at 02:51