なるようになるブログ

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

rails commit log流し読み(2024/02/10)

2024/02/10分のコミットです。

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

railties/CHANGELOG.md

activestorage/CHANGELOG.md

activerecord/CHANGELOG.md


Workaround a Ruby bug that can cause a VM crash

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

object_idにアクセス済みのProc objectのcloneがあり、そのcloneがGCされた場合にRubyがクラッシュしてしまう、というバグがリリース済みのRubyにあり、そのバグの回避策として、cloneした方のobjectでもobject_idを参照するよう修正しています。

参考: Bug #20250: Crash with "Object ID seen, but not in mapping table: proc" error - Ruby master - Ruby Issue Tracking System


Fixes race condition when multiple preprocessed variants are defined for a Previewable file is attached

Active Storageの修正です。

attachmentにvariantが複数定義されている、かつ、variantにpreviewableなtypeが指定されている、かつ、それぞれにpreprocessed: trueが指定されている場合に、fileがattachされた際にそれぞれのvariantでpreview用のファイル生成処理が同時に実行されてしまい、結果不要なファイルやattachmntと紐付かないファイル(attachmentをpurgeしても消えないファイル)が生成されてしまうバグがあったのを修正しています。


Prefer to reference git's default configuration, not bespoke

railties/lib/rails/generators/rails/app/templates/gitignore.ttのコメントの修正です。

git ignoreの設定をする際に、独自のglobalのexcludesfileを設定するよう説明していたのを、gitがデフォルトで参照するignore fileを使用するよう説明を修正しています。


Disambiguate language around when code stops re: redirect_to

rails guideのLayouts and Rendering in Railsの修正です。

The Difference Between render and redirect_toセクションの言い回しを修正しています。


docs:expand documentation on has_one_attached method.

activestorage/lib/active_storage/attached/model.rbのdocの修正です。

has_one_attachedメソッドのdoc内の:dependentオプションについて説明している箇所に:purge_laterオプションについての説明を追加しています。


Merge pull request #51006 from kddnewton/parse-with-prism

railties/lib/rails/test_unit/test_parser.rbの修正です。

TestUnit::TestParserで使用できる場合ripperではなくprismを使用してパース処理を行うよう修正しています。


Transform actionpack documentation to Markdown

Action Packのdocの修正です。

docのフォーマットをMarkdownに変更しています。


Update activestorage/app/models/active_storage/blob/representable.rb

activestorage/app/models/active_storage/blob/representable.rbのdocの修正です。

内部用のAPIAPI docに表示されないよう修正しています。


Merge pull request #49897 from glaucocustodio/main

rails guideのAction Cable Overviewの修正です。

PostgreSQL Adapterセクションに、PostgreSQLNOTIFYにはデータサイズが8000 bytesまでであるという制限がある旨説明を追加しています。

参考: PostgreSQL: Documentation: 16: NOTIFY


Add class name to enum validation exception message

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

enumの定義処理でエラーになった場合のエラーメッセージにエラーになったクラス名を含むよう修正しています。


Merge pull request #51017 from p8/activesupport/document-time-zone-create

activesupport/lib/active_support/values/time_zone.rbのdocの修正です。

ActiveSupport::TimeZone.createメソッドのdocが正しく表示されるようフォーマットの修正を行っています。


Merge pull request #50992 from KJTsanaktsidis/ktsanaktsidis/persist_logger_tags_until_as_event

railties/lib/rails/rack/logger.rbの修正です。

config.log_tagsで設定したloggerのtagの設定が、request.action_dispatch handler内でも使用されるよう修正しています。


Add WebP as a new framework default image type

railties/lib/rails/application/configuration.rbの修正です。

Rails 7.2以降の設定が有効になっている場合、image/webpをActive Storageのデフォルトのimage typeに追加するよう修正しています。


Add note about imagemagick / libvips support being required

railties/lib/rails/generators/rails/app/templates/config/initializers/new_framework_defaults_7_2.rb.ttの修正です。

WebPを使用する場合、imagemagick/libvipsがWebPをサポートする設定になっている必要がある旨コメントを追加しています。


Fix configuration order

rails guideのConfiguring Rails Applicationsの修正です。

config名の並びをアルファベット順に修正しています。


Deprecate defining enums with keywords args

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

enumをkeyword argsを使用してい定義する処理をdeprecatedにしています。

class Function > ApplicationRecord
  enum color: [:red, :blue],
       type: [:instance, :class]
end

上記書き方はNGで、下記のようにenum毎に定義する必要があります。

class Function > ApplicationRecord
  enum :color, [:red, :blue]
  enum :type, [:instance, :class]
end

元々は前者の書き方しか出来なかったのですが、Rails 7.0から後者の書き方が出来るようになった、かつ、オプションを定義する際に_を使用しないで良い等のメリットがあり、前者の書き方をサポートし続ける必要は無くなっている為、deprecatedにしています。


Update 7.0 release notes re inflections and the once autoloader

rails guideのUpgrading Ruby on Railsの修正です。

Autoloading during initializationセクションに、once autoloaderでロードされる処理でinflectionの設定をしたい場合、config/initializers/inflections.rbではなく、config/application.rbにそのinflectionを定義する必要がある旨説明を追加しています。