なるようになるブログ

読書感想文かrailsについてかrubyについてか

rails commit log流し読み(2022/10/21)

2022/10/21分のコミットです。

CHANGELOGにのったコミットは以下の通りです。

activerecord/CHANGELOG.md

activesupport/CHANGELOG.md


Fix missed deprecations

activerecord/lib/active_record/railtie.rbの修正です。

Deprecate delegation to connection handler from Baseの対応の際に修正漏れがあったのを対応しています。


Fix ciphertext_for for yet-to-be-encrypted values

activerecord/lib/active_record/encryption/encryptable_record.rbの修正です。

ciphertext_forメソッドが、値がDBに保存されていない場合などに平文を返してしまっていたのを、返せる場合は暗号化した値を返すよう修正しています。

Post.encrypts :body
post = Post.create!(body: "Hello")


# Before
post.body = "World"
post.ciphertext_for(:body)
# => "World"

# After
post.body = "World"
post.ciphertext_for(:body)
# => "{\"p\":\"xyz..."

Avoid value_for_database if attribute not updated

activemodel/lib/active_model/attribute.rbの修正です。

attributeが更新されていない場合、不要なvalue_for_databaseメソッドの呼び出しを行わないよう修正しています。


Fix Action View compatibility with jbuilder

actionview/lib/action_view/renderer/abstract_renderer.rbactionview/lib/action_view/template.rbの修正です。

RenderedTemplatebody引数がStringのみを想定していたのを、String以外の場合も動作するよう修正しています。jbuilderbodyにHashを指定する為。


Allow ErrorReporter to handle several error classes

activesupport/lib/active_support/error_reporter.rbの修正です。

Rails.error.handle 及び Rails.error.recordで処理を行う対象のエラークラスに、複数のクラスを指定出来るよう修正しています。

Rails.error.handle(ArgumentError, TypeError) do
  [1, 2, 3].first(x)
end