aboutsummaryrefslogtreecommitdiffstats
path: root/guides
diff options
context:
space:
mode:
authorEileen M. Uchitelle <eileencodes@users.noreply.github.com>2018-08-30 13:07:02 -0400
committerGitHub <noreply@github.com>2018-08-30 13:07:02 -0400
commit8f2caec401c8e97d9eb1ea84d8263911c50e1ed6 (patch)
tree5845f95505c0cc35c62e55434b0b45e1104a2d60 /guides
parent616afba436b16210c03c323f698e2c3603f16a9f (diff)
parentfdf3f0b9306ba8145e6e3acb84a50e5d23dfe48c (diff)
downloadrails-8f2caec401c8e97d9eb1ea84d8263911c50e1ed6.tar.gz
rails-8f2caec401c8e97d9eb1ea84d8263911c50e1ed6.tar.bz2
rails-8f2caec401c8e97d9eb1ea84d8263911c50e1ed6.zip
Merge pull request #33637 from eileencodes/ar-connection-management-refactoring
Refactor Active Record configurations
Diffstat (limited to 'guides')
-rw-r--r--guides/source/configuring.md32
1 files changed, 28 insertions, 4 deletions
diff --git a/guides/source/configuring.md b/guides/source/configuring.md
index 7265d1e05f..8c95187fa4 100644
--- a/guides/source/configuring.md
+++ b/guides/source/configuring.md
@@ -911,7 +911,15 @@ $ echo $DATABASE_URL
postgresql://localhost/my_database
$ rails runner 'puts ActiveRecord::Base.configurations'
-{"development"=>{"adapter"=>"postgresql", "host"=>"localhost", "database"=>"my_database"}}
+#<ActiveRecord::DatabaseConfigurations:0x00007fd50e209a28>
+
+$ rails runner 'puts ActiveRecord::Base.configurations.inspect'
+#<ActiveRecord::DatabaseConfigurations:0x00007fc8eab02880 @configurations=[
+ #<ActiveRecord::DatabaseConfigurations::UrlConfig:0x00007fc8eab020b0
+ @env_name="development", @spec_name="primary",
+ @config={"adapter"=>"postgresql", "database"=>"my_database", "host"=>"localhost"}
+ @url="postgresql://localhost/my_database">
+ ]
```
Here the adapter, host, and database match the information in `ENV['DATABASE_URL']`.
@@ -928,7 +936,15 @@ $ echo $DATABASE_URL
postgresql://localhost/my_database
$ rails runner 'puts ActiveRecord::Base.configurations'
-{"development"=>{"adapter"=>"postgresql", "host"=>"localhost", "database"=>"my_database", "pool"=>5}}
+#<ActiveRecord::DatabaseConfigurations:0x00007fd50e209a28>
+
+$ rails runner 'puts ActiveRecord::Base.configurations.inspect'
+#<ActiveRecord::DatabaseConfigurations:0x00007fc8eab02880 @configurations=[
+ #<ActiveRecord::DatabaseConfigurations::UrlConfig:0x00007fc8eab020b0
+ @env_name="development", @spec_name="primary",
+ @config={"adapter"=>"postgresql", "database"=>"my_database", "host"=>"localhost", "pool"=>5}
+ @url="postgresql://localhost/my_database">
+ ]
```
Since pool is not in the `ENV['DATABASE_URL']` provided connection information its information is merged in. Since `adapter` is duplicate, the `ENV['DATABASE_URL']` connection information wins.
@@ -938,13 +954,21 @@ The only way to explicitly not use the connection information in `ENV['DATABASE_
```
$ cat config/database.yml
development:
- url: sqlite3:NOT_my_database
+ url: sqlite3://NOT_my_database
$ echo $DATABASE_URL
postgresql://localhost/my_database
$ rails runner 'puts ActiveRecord::Base.configurations'
-{"development"=>{"adapter"=>"sqlite3", "database"=>"NOT_my_database"}}
+#<ActiveRecord::DatabaseConfigurations:0x00007fd50e209a28>
+
+$ rails runner 'puts ActiveRecord::Base.configurations.inspect'
+#<ActiveRecord::DatabaseConfigurations:0x00007fc8eab02880 @configurations=[
+ #<ActiveRecord::DatabaseConfigurations::UrlConfig:0x00007fc8eab020b0
+ @env_name="development", @spec_name="primary",
+ @config={"adapter"=>"sqlite3", "database"=>"NOT_my_database", "host"=>"localhost"}
+ @url="sqlite3://NOT_my_database">
+ ]
```
Here the connection information in `ENV['DATABASE_URL']` is ignored, note the different adapter and database name.