diff options
author | Terence Lee <hone02@gmail.com> | 2013-02-21 01:13:10 +1100 |
---|---|---|
committer | Terence Lee <hone02@gmail.com> | 2013-02-21 01:25:05 +1100 |
commit | 4bdaf95b82a1358b11bbfb857a1ac2790136a4ef (patch) | |
tree | 3882f08781365e81a2aa9f3046d7175b2dae4574 /activerecord | |
parent | ebae71a67a6c4d0421efd932b2af88c48b8b1c7c (diff) | |
download | rails-4bdaf95b82a1358b11bbfb857a1ac2790136a4ef.tar.gz rails-4bdaf95b82a1358b11bbfb857a1ac2790136a4ef.tar.bz2 rails-4bdaf95b82a1358b11bbfb857a1ac2790136a4ef.zip |
standardize database_configuration to a hash
make connection_url_to_hash a class method
This als prevents loading database.yml if it doesn't exist
but DATABASE_URL does
Diffstat (limited to 'activerecord')
-rw-r--r-- | activerecord/lib/active_record/connection_adapters/connection_specification.rb | 4 | ||||
-rw-r--r-- | activerecord/lib/active_record/railtie.rb | 4 |
2 files changed, 3 insertions, 5 deletions
diff --git a/activerecord/lib/active_record/connection_adapters/connection_specification.rb b/activerecord/lib/active_record/connection_adapters/connection_specification.rb index 873f1ad3d4..5b60185f53 100644 --- a/activerecord/lib/active_record/connection_adapters/connection_specification.rb +++ b/activerecord/lib/active_record/connection_adapters/connection_specification.rb @@ -38,7 +38,7 @@ module ActiveRecord private def resolve_string_connection(spec) # :nodoc: hash = configurations.fetch(spec) do |k| - connection_url_to_hash(k) + self.class.connection_url_to_hash(k) end raise(AdapterNotSpecified, "#{spec} database is not configured") unless hash @@ -69,7 +69,7 @@ module ActiveRecord SIMPLE_INT = /\A\d+\z/ SIMPLE_FLOAT = /\A\d+\.\d+\z/ - def connection_url_to_hash(url) # :nodoc: + def self.connection_url_to_hash(url) # :nodoc: config = URI.parse url adapter = config.scheme adapter = "postgresql" if adapter == "postgres" diff --git a/activerecord/lib/active_record/railtie.rb b/activerecord/lib/active_record/railtie.rb index aceb70bc45..a979be6999 100644 --- a/activerecord/lib/active_record/railtie.rb +++ b/activerecord/lib/active_record/railtie.rb @@ -141,9 +141,7 @@ module ActiveRecord # and then establishes the connection. initializer "active_record.initialize_database" do |app| ActiveSupport.on_load(:active_record) do - unless ENV['DATABASE_URL'] - self.configurations = app.config.database_configuration - end + self.configurations = app.config.database_configuration establish_connection end end |