なるようになるブログ

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

rails commit log流し読み(2023/09/05)

2023/09/05分のコミットです。

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

activejob/CHANGELOG.md

activerecord/CHANGELOG.md

actionview/CHANGELOG.md


Merge pull request #47865 from bensheldon/enqueue-error-message

activejob/lib/active_job/log_subscriber.rbの修正です。

adapterがActiveJob::EnqueueErrorをraiseしてjobのenqueueに失敗した場合に、logにその失敗の原因が正しく記録されない問題があったのを修正しています。


Merge pull request #49134 from fatkodima/fix-ar-tests-warnings

Active Recordの修正です。

ActiveSupport::Deprecationを使用していた箇所をActiveRecord.deprecatorを使用するよう修正、及び、assert_deprecatedにdeprecatorを指定するよう修正しています。


Merge pull request #49136 from fatkodima/fix-counter-caches-var-modification

activerecord/lib/active_record/associations/builder/belongs_to.rbの修正です。

counter_cacheに使用しているcolumnに明示的に値を指定して更新処理を行った場合に、値が更新されないバグがあったのを修正しています。


Merge pull request #49133 from fatkodima/fix-has_secure_token-when-not-selected-column

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

has_secure_tokenon: :initializeを指定している、かつ、has_secure_tokenに指定しているcolumnがロードされない場合(e.g. selectでロードするcolumnを限定している場合)にエラーになってしまうバグがあったのを修正しています。


Generate secure token only once regardless of on: :initialize or on: :create

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

has_secure_tokenon: :initializeを指定している場合に、初期化だけでなくrecord保存時にもtokenの生成がされていたのを、初期化時にのみtokenの生成を行うよう修正しています。


Don't modify existing test model in a test case

activerecord/test/cases/secure_token_test.rbの修正です。

has_secure_tokenのテストで、テスト全体で使用するmodelのメソッドをundefしていたのを、該当のテストでだけ使用するmodelを定義しそちらを使用するよう修正しています。他のテストに影響が出ないようにする為。


Fix a test added in #48912 to work on a model with on: :initialize

activerecord/test/cases/secure_token_test.rbの修正です。

has_secure_tokenon: :initializeを指定している場合のテストで、実際にはon: :initializeが指定されていなかったのを修正しています。


Fix test_generating_token_on_initialize_does_not_affect_reading_from_the_column

activerecord/test/cases/secure_token_test.rbの修正です。

先のコミットで修正したテストがfailしてしまっていたのを修正しています。


Fix: simple_format with blank wrapper_tag option returns plain html tag.

actionview/lib/action_view/helpers/text_helper.rbの修正です。

simple_formatwrapper_tagオプションにnilを指定した場合に、tag名が指定されていない不正なHTMLが生成されていたのを、<p>タグでwrapしたHTMLを返すよう修正しています。

Before:

simple_format("Hello World", {},  { wrapper_tag: nil })
# => <>Hello World</>

After:

simple_format("Hello World", {},  { wrapper_tag: nil })
# => <p>Hello World</p>

[skip ci] Minor formatting fixes for code blocks

rails guideのRuby on Rails 7.1 Release Notesの修正です。

code exampleのフォーマットの修正を行っています。


[skip ci] rewhere argument on #merge deprecated

activerecord/CHANGELOG.mdの修正です。

mergeメソッドのrewhere引数をdeprecatedにした、Deprecate passing rewhere to mergeの対応についてCHANGELOGにエントリーを追加しています。


Mention composite primary keys for migrations and querying

rails guideのActive Record Migrations、及び、Active Record Query Interfaceの修正です。

findメソッド、及び、create_tableメソッドについて説明している箇所に、composite primary keyを使用する場合の説明を追加しています。


Remove internal usage of require_dependency

actionmailer/lib/action_mailer/preview.rbの修正です。

require_dependencyを使用している箇所をrequireを使用するよう修正しています。require_dependencyは現在obsoleteになっている為。


Active Record query guide: add a composite primary key example for find

rails guideのActive Record Query Interfaceの修正です。

composite primary keyを使用しているmodelに対してfindを実行した場合のexampleを追加しています。