diff --git a/activerecord/CHANGELOG b/activerecord/CHANGELOG index 212f7b179d..25c633a47d 100644 --- a/activerecord/CHANGELOG +++ b/activerecord/CHANGELOG @@ -1,5 +1,7 @@ *SVN* +* RubyGem database adapters: expects a gem named activerecord--adapter with active_record/connection_adapters/_adapter.rb in its load path. [Jeremy Kemper] + * Added block-acceptance to JavaScriptHelper#javascript_tag #7527 [BobSilva/tarmo/rmm5t] * Fixed that altering join tables in migrations would fail w/ sqlite3 #7453 [TimoMihaljov/brandon] diff --git a/activerecord/lib/active_record/connection_adapters/abstract/connection_specification.rb b/activerecord/lib/active_record/connection_adapters/abstract/connection_specification.rb index 918c29114c..cd3b53d831 100644 --- a/activerecord/lib/active_record/connection_adapters/abstract/connection_specification.rb +++ b/activerecord/lib/active_record/connection_adapters/abstract/connection_specification.rb @@ -206,10 +206,26 @@ module ActiveRecord else spec = spec.symbolize_keys unless spec.key?(:adapter) then raise AdapterNotSpecified, "database configuration does not specify adapter" end - adapter_method = "#{spec[:adapter]}_connection" - require "active_record/connection_adapters/#{spec[:adapter]}_adapter" - unless respond_to?(adapter_method) + tried_gem = false + begin + require "active_record/connection_adapters/#{spec[:adapter]}_adapter" + rescue LoadError + raise if tried_gem + + begin + require 'rubygems' + gem "activerecord-#{spec[:adapter]}-adapter" + rescue LoadError + raise "Please install the #{spec[:adapter]} adapter: `gem install activerecord-#{spec[:adapter]}-adapter` (#{$!})" + end + + tried_gem = true + retry + end + + adapter_method = "#{spec[:adapter]}_connection" + if !respond_to?(adapter_method) raise AdapterNotFound, "database configuration specifies nonexistent #{spec[:adapter]} adapter" end