diff options
author | eileencodes <eileencodes@gmail.com> | 2019-02-12 15:42:44 -0500 |
---|---|---|
committer | eileencodes <eileencodes@gmail.com> | 2019-02-14 08:25:52 -0500 |
commit | 06f9434342d636b18229953a8f50ee5d989f4c75 (patch) | |
tree | ae787a8a3bf1dc5ef835edb1648c698825c0bf7c /activestorage/lib/active_storage | |
parent | 1bbf08bb497a022f94c7309e0525071b1a65e272 (diff) | |
download | rails-06f9434342d636b18229953a8f50ee5d989f4c75.tar.gz rails-06f9434342d636b18229953a8f50ee5d989f4c75.tar.bz2 rails-06f9434342d636b18229953a8f50ee5d989f4c75.zip |
Improve errors and handling of hashes for database configurations
In chat Sam Saffron asked how to use the setter now that configurations
is no longer a hash and you need to do AR::Base.configurations["test"]=.
Technically you can do `ActiveRecord::Base.configurations = { the hash
}` but I realized the old way throws an error and is unintuitive.
To aid in the transition from hashes to objects this PR makes a few
changes:
1) Re-adds a deprecated hash setter `[]=` that will add a new hash
to the configurations list OR replace an existing hash if that
environment is already present. This won't be supported in future Rails
versions but a good error is important.
2) Changed to throw deprecation warnings on the methods we decided to support
for hash conversion and raise on the methods we don't support.
3) Refactored the setter/getter hash deprecation warnings messages and
rewrote them.
Getters message:
```
DEPRECATION WARNING: `ActiveRecord::Base.configurations` no longer
returns a hash. Methods that act on the hash like `values` are
deprecated and will be removed in Rails 6.1. Use the `configs_for`
method to collect and iterate over the database configurations.
```
Setter message:
```
DEPRECATION WARNING: Setting `ActiveRecord::Base.configurations` with
`[]=` is deprecated. Use `ActiveRecord::Base.configurations=` directly
to set the configurations instead.
```
4) Rewrote the legacy configurations test file to test all the public
methods in the DatabaseConfigurations class.
Diffstat (limited to 'activestorage/lib/active_storage')
0 files changed, 0 insertions, 0 deletions