aboutsummaryrefslogtreecommitdiffstats
path: root/railties/lib/rails
diff options
context:
space:
mode:
authorHuiming Teo <teohuiming@gmail.com>2013-12-15 14:07:34 +0800
committerHuiming Teo <teohuiming@gmail.com>2013-12-16 18:31:49 +0800
commit971d5107cd4cd08c22a85d34546f4ba03ed5c925 (patch)
tree0ab76fd08ee4c2f776127432b408dd286be36afc /railties/lib/rails
parentfc83efae516fc572551b3f1d67a12394800dd4e2 (diff)
downloadrails-971d5107cd4cd08c22a85d34546f4ba03ed5c925.tar.gz
rails-971d5107cd4cd08c22a85d34546f4ba03ed5c925.tar.bz2
rails-971d5107cd4cd08c22a85d34546f4ba03ed5c925.zip
fixed rails dbconsole to support ENV['DATABASE_URL'].
Diffstat (limited to 'railties/lib/rails')
-rw-r--r--railties/lib/rails/commands/dbconsole.rb13
1 files changed, 5 insertions, 8 deletions
diff --git a/railties/lib/rails/commands/dbconsole.rb b/railties/lib/rails/commands/dbconsole.rb
index 3e4cc787c4..847447fdad 100644
--- a/railties/lib/rails/commands/dbconsole.rb
+++ b/railties/lib/rails/commands/dbconsole.rb
@@ -81,14 +81,11 @@ module Rails
def config
@config ||= begin
- cfg = begin
- YAML.load(ERB.new(IO.read("config/database.yml")).result)
- rescue SyntaxError, StandardError
- require APP_PATH
- Rails.application.config.database_configuration
- end
-
- cfg[environment] || abort("No database is configured for the environment '#{environment}'")
+ require APP_PATH
+ ActiveRecord::ConnectionAdapters::ConnectionSpecification::Resolver.new(
+ ENV['DATABASE_URL'],
+ (Rails.application.config.database_configuration || {})
+ ).spec.config.stringify_keys
end
end