rails/init.rb in spatial_adapter-0.3.1 vs rails/init.rb in spatial_adapter-1.0.0
- old
+ new
@@ -1,15 +1,30 @@
-require 'spatial_adapter'
+# Rails initialization
+#
+# This will load the adapter for the currently used database configuration, if
+# it exists.
+
+module SpatialAdapter
+ class NotCompatibleError < ::StandardError
+ end
+end
+
+begin
+ adapter = ActiveRecord::Base.configurations[RAILS_ENV]['adapter']
+ require "spatial_adapter/#{adapter}"
+rescue LoadError
+ raise SpatialAdapter::NotCompatibleError.new("spatial_adapter does not currently support the #{adapter} database.")
+end