From ed9d220cd1710fcfe74f61a092b8e3b42ed426da Mon Sep 17 00:00:00 2001 From: Akira Matsuda Date: Wed, 10 Sep 2014 19:25:01 +0900 Subject: Tell the user which file is missing when config/database.yml was not found Since cc03675d30b58e28f585720dad14e947a57ff5b the error message became like "Could not load database configuration. No such file -" which doesn't really tell what's actually missing. --- railties/lib/rails/application/configuration.rb | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) (limited to 'railties/lib/rails/application/configuration.rb') diff --git a/railties/lib/rails/application/configuration.rb b/railties/lib/rails/application/configuration.rb index 2c16b83f8a..786dcee007 100644 --- a/railties/lib/rails/application/configuration.rb +++ b/railties/lib/rails/application/configuration.rb @@ -93,9 +93,10 @@ module Rails # Loads and returns the entire raw configuration of database from # values stored in `config/database.yml`. def database_configuration - yaml = Pathname.new(paths["config/database"].existent.first || "") + path = paths["config/database"].existent.first + yaml = Pathname.new(path) if path - config = if yaml.exist? + config = if yaml && yaml.exist? require "yaml" require "erb" YAML.load(ERB.new(yaml.read).result) || {} @@ -104,7 +105,7 @@ module Rails # by Active Record. {} else - raise "Could not load database configuration. No such file - #{yaml}" + raise "Could not load database configuration. No such file - #{paths["config/database"].instance_variable_get(:@paths)}" end config -- cgit v1.2.3