diff options
author | Jeremy Kemper <jeremy@bitsweat.net> | 2007-09-15 23:21:21 +0000 |
---|---|---|
committer | Jeremy Kemper <jeremy@bitsweat.net> | 2007-09-15 23:21:21 +0000 |
commit | f92503c5416256d2630abc7304c02e6aec50d5a0 (patch) | |
tree | 6dd61c35677e99415b1ea7de0507642525f97f3c | |
parent | c30c1808c0da2bfd34baf613fd8e1a4b685e8d94 (diff) | |
download | rails-f92503c5416256d2630abc7304c02e6aec50d5a0.tar.gz rails-f92503c5416256d2630abc7304c02e6aec50d5a0.tar.bz2 rails-f92503c5416256d2630abc7304c02e6aec50d5a0.zip |
RubyGem database adapters: expects a gem named activerecord-<database>-adapter with active_record/connection_adapters/<database>_adapter.rb in its load path.
git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@7491 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
-rw-r--r-- | activerecord/CHANGELOG | 2 | ||||
-rw-r--r-- | activerecord/lib/active_record/connection_adapters/abstract/connection_specification.rb | 22 |
2 files changed, 21 insertions, 3 deletions
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-<database>-adapter with active_record/connection_adapters/<database>_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 |