diff options
author | Yves Senn <yves.senn@garaio.com> | 2012-10-29 09:02:48 +0100 |
---|---|---|
committer | Yves Senn <yves.senn@gmail.com> | 2013-02-20 10:54:58 +0100 |
commit | 0a6b61a5f534c07406f1ec2de11b4a53ce81151d (patch) | |
tree | 2a99eab6af1b734ac8e092225c3ec072943e854d /activerecord/lib | |
parent | c3f1b1d3cdb837a24d66b80deda39cfe23856724 (diff) | |
download | rails-0a6b61a5f534c07406f1ec2de11b4a53ce81151d.tar.gz rails-0a6b61a5f534c07406f1ec2de11b4a53ce81151d.tar.bz2 rails-0a6b61a5f534c07406f1ec2de11b4a53ce81151d.zip |
descriptive error message when AR adapter was not found. Closes #7313.
Diffstat (limited to 'activerecord/lib')
-rw-r--r-- | activerecord/lib/active_record/connection_adapters/connection_specification.rb | 7 |
1 files changed, 5 insertions, 2 deletions
diff --git a/activerecord/lib/active_record/connection_adapters/connection_specification.rb b/activerecord/lib/active_record/connection_adapters/connection_specification.rb index 577a362568..873f1ad3d4 100644 --- a/activerecord/lib/active_record/connection_adapters/connection_specification.rb +++ b/activerecord/lib/active_record/connection_adapters/connection_specification.rb @@ -51,10 +51,13 @@ module ActiveRecord raise(AdapterNotSpecified, "database configuration does not specify adapter") unless spec.key?(:adapter) + path_to_adapter = "active_record/connection_adapters/#{spec[:adapter]}_adapter" begin - require "active_record/connection_adapters/#{spec[:adapter]}_adapter" + require path_to_adapter + rescue Gem::LoadError => e + raise Gem::LoadError, "Specified '#{spec[:adapter]}' for database adapter, but the gem is not loaded. Add `gem '#{e.name}'` to your Gemfile." rescue LoadError => e - raise LoadError, "Please install the #{spec[:adapter]} adapter: `gem install activerecord-#{spec[:adapter]}-adapter` (#{e.message})", e.backtrace + raise LoadError, "Could not load '#{path_to_adapter}'. Make sure that the adapter in config/database.yml is valid. If you use an adapter other than 'mysql', 'mysql2', 'postgresql' or 'sqlite3' add the necessary adapter gem to the Gemfile.", e.backtrace end adapter_method = "#{spec[:adapter]}_connection" |