Skip to content

Commit

Permalink
fix-Mysql2AdapterUndefinedMethodLoaded
Browse files Browse the repository at this point in the history
Mysql2 was present in Adapters.constants as a Module, and require was never called, resulting in Undefined method exception. Make sure the require is called if the const_get returns a Module and not a Class
  • Loading branch information
IgorMiller committed Dec 2, 2015
1 parent 45ae985 commit 18beb94
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions lib/geokit-rails/acts_as_mappable.rb
Expand Up @@ -98,6 +98,13 @@ def adapter
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
klass.new(self)
rescue LoadError
Expand Down

0 comments on commit 18beb94

Please sign in to comment.