2018/09/20分のコミットです。
CHANGELOGにのったコミットは以下の通りです。
- Deprecate
ActiveRecord::Result#to_hash
in favor ofActiveRecord::Result#to_a
. - Don't update counter cache unless the record is actually saved.
Don't return the same object when using find with an empty array
activerecord/lib/active_record/relation/finder_methods.rb
の修正です。
find
メソッドに空のArrayを指定した場合に、引数のArrayがそのまま戻り値になっていたのを、新しいArrayのインスタンスを生成し、そちらを返すよう修正しています。
Support environment specific credentials file. (#33521)
railtiesの修正です。
credentialsファイルをenv毎に管理出来るようになりました。
credentials:edit
、credentials:show
コマンドにenvオプションを指定出来るようになっています。
$ EDITOR=vim ./bin/rails credentials:edit -e production Adding config/credentials/production.key to store the encryption key: xxx Save this in a password manager your team can access. If you lose the key, no one, including you, can access anything encrypted with it. create config/credentials/production.key Ignoring config/credentials/production.key so it won't end up in Git history: append .gitignore File encrypted and saved.
./bin/rails credentials:show -e production # aws: # access_key_id: 123 # secret_access_key: 345
env毎のcredentials、及び、keyはconfig/credentials
ディレクトリ配下に生成されます(envがproductionの場合はproduction.key
、及び、production.yml.enc
)。keyを環境変数で指定したい場合は、既存のcredentials同様RAILS_MASTER_KEY
で指定可能です(環境変数はenv問わず同じ)。
なお、credentialファイルは、env毎のcredentialファイル -> 共通のcredentialファイル(config/credentials.yml.enc
)の順で検索されるようになっており、先に見つかったファイルが使用されます。内容のmergeは行われないので、env毎のcredentialファイルが使用される場合config/credentials.yml.enc
はロードされません。
Merge pull request #32932 from y-yagi/fixes_32920
actionpack/lib/action_dispatch/http/content_security_policy.rb
の修正です。
Content Security Policyのstyle-src
directiveでnonce
が使用出来るよう修正しています。使用されるnonce
はscript-src
で使用するのと同じ値です。
railtiesの修正です。
各docで、env毎のcredentialsで使用されるenv keyの値が誤っていたのを修正しています。が、これは勘違いで、docは正しくて実装がおかしいだけでした。
Merge pull request #33912 from gmcgibbon/ar_result_to_hash_deprecate
activerecord/lib/active_record/result.rb
の修正です。
ActiveRecord::Result#to_hash
メソッドがdeprecateになりました。今後は代わりに、ActiveRecord::Result#to_a
メソッドを使用する必要があります。
元々、to_hash
メソッドという名前なのに戻り値はArrayで紛らわしい、という問題があった為、to_a
にメソッド名が変更される事になりました。戻り値はto_hash
と変わらずです。
Merge pull request #33913 from kamipo/counter_cache
Active Recordの修正です。
recordが実際に保存された時にcounter cacheの値を更新するよう修正しています。
これにより、counter cacheが2回インクリメント / デクリメントされてしまう、インクリメントがされない、というようなバグがあったのが修正されています。
Merge pull request #33927 from bogdanvlviv/follow-up-33912
activerecord/lib/active_record/result.rb
の修正です。
ActiveRecord::Result#to_a
をActiveRecord::Result#to_ary
のaliasとして定義するよう修正しています。
Fix deprecation hash warning - activerecord test
activerecord/test/cases/adapter_test.rb
の修正です。
deprecateになったactiverecord::Result#to_hash
メソッドをテスト内で使っている箇所があったのを、to_a
メソッドを使用するよう修正しています。
Fixed to RAILS_MASTER_KEY as a default env key for decrypting.
railtiesの修正です。
env毎のcredentialsで、keyを環境変数から取得する場合のkeyにRAILS_MASTER_KEY
を使用するよう修正しています。環境変数については、env問わず同じkeyを使うのが良いだろう、という事でそうなったとの事です。
Update MySQL server version and character set in Rails Guide [skip ci]
rails guideのConfiguring Rails Applications
の修正です。
Configuring a MySQL or MariaDB Database
の項にあるdatabase.yml
のexampleからencoding
の指定を削除、及び、MySQLのバージョンが5.5、5.6でutf8mb4
を使用する場合、innodb_large_prefix
を有効化する必要がある説明を追加しています。