This is due to faulty logic in geokit_finder_adapter:
# A proxy to an instance of a finder adapter, inferred from the connection's adapter.
def geokit_finder_adapter
@geokit_finder_adapter ||= begin
unless Adapters.const_defined?(connection.adapter_name.camelcase)
filename = connection.adapter_name.downcase
require File.join("geokit-rails", "adapters", filename)
end
klass = Adapters.const_get(connection.adapter_name.camelcase)
if klass.class == Module
# For some reason Mysql2 adapter was defined in Adapters.constants but was Module instead of a Class
filename = connection.adapter_name.downcase
require File.join("geokit-rails", "adapters", filename)
# Re-init the klass after require
klass = Adapters.const_get(connection.adapter_name.camelcase)
end
klass.load(self) unless klass.loaded || skip_loading
klass.new(self)
rescue LoadError
raise UnsupportedAdapter, "`#{connection.adapter_name.downcase}` is not a supported adapter."
end
end
The call to const_defined and const_get should pass the extra 'false' parameter - otherwise they will find the top-level '::Mysql2' constant and return that instead. ie:
irb(main):001:0> module X1; module X2; end; end
irb(main):004:0> module X2; end
irb(main):005:0> module X3; end
irb(main):006:0> X3.const_defined?('X2')
=> true
irb(main):007:0> X3.const_defined?('X2', false)
=> false
irb(main):008:0> X1.const_defined?('X2', false)
=> true
This is due to faulty logic in geokit_finder_adapter:
The call to const_defined and const_get should pass the extra 'false' parameter - otherwise they will find the top-level '::Mysql2' constant and return that instead. ie: