なるようになるブログ

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

rails commit log流し読み(2021/12/21)

2021/12/21分のコミットです。

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

activerecord/CHANGELOG.md

activesupport/CHANGELOG.md


update delete example using turbo

rails guideのGetting Started with Railsの修正です。

Deleting an Articleの項にあるデータ削除のexamleコードを、Turboを使う前提のコードに修正しています。


Revert "Merge pull request #43604 from nikonoid/bug/31722"

ActiveRecord::Migration next_migration_numberでmigration numberの生成を行う際に値の比較をIntegerに変換してから行うよう修正した、 ActiveRecord::Migration next_migration_number should use numeric version comparison.をRevertしています。breaking changeになってしまったのと、timestamped migrationsのフォーマットにちゃんと従っていれば不要な対応の筈の為。


Remove unneeded test

railties/test/generators/plugin_generator_test.rbの修正です。

rails newに現在は存在しないオプションを使用したテストがあったのを削除しています。


Make sure plugin generator works with dummy app

railties/lib/rails/generators/app_base.rbrailties/lib/rails/generators/rails/plugin/templates/Gemfile.ttの修正です。

dummy applicationのGemfilesprockets-railsを追加するよう修正しています。dummy applicationはsprocketsにまだ依存しており、gemが無いとエラーになってしまう為。


Merge pull request #43900 from yykamei/initialize-with-logging_context

actionpack/lib/action_controller/metal/strong_parameters.rbの修正です。

ActionController::Parametersの一部メソッド実行時に、元々インスタンスで保持していたaction名やcontroller名のコンテキストが失われしまうバグがあったのを修正しています。


Fix logger format with Ruby 3.1

activesupport/test/clean_logger_test.rbの修正です。

Ruby 3.1でloggerのformatが変更になった事によりエラーになってしまたテストがあったのを修正しています。


Merge pull request #43811 from eikes/migrations-guide-foreign-key-deferrable

rails guideのActive Record Migrationsの修正です。

add_foreign_keyメソッドについて説明している箇所について、API docへのリンクの追加、不要なオプションの削除等を行っています。


Merge pull request #43914 from orhantoy/add-only-numeric-option-to-numericality-validator

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

numericality validatorに、numericな値だけかどうかをチェックする為のonly_numericオプションを追加しています。only_numericがtrueの場合、"120"のようなnumericに変換すると正常な値だけどStringな値が指定された場合エラーになるようになっています。


Merge pull request #43916 from Shopify/activerecord-in-order-of-empty-array

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

QueryMethods#in_order_ofのorder listに空の配列を指定した場合、実行時にエラーになってしまっていたのを、エラーにならないよう修正しています。空の配列が指定された場合、デフォルトのorderingが使用されるようになっています。


Merge pull request #43918 from ghiculescu/link-to-model-twice

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

link_toにmodelを引数に2回渡した場合(e.g. link_to @article, @article)にエラーになってしまうバグがあったのを修正しています。


Merge PR #43389

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

polymorphic relationship をthroughしてjoin処理を行った場合に、エラーになってしまうバグがあったのを修正しています。


Merge PR #43157

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

button_toにblock + HashでURLを指定した場合に、誤った内容のbutton tagが生成されてしまうバグがあったのを修正しています。


Fix #43918

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

Merge pull request #43918 from ghiculescu/link-to-model-twice で必要な変数の初期化処理を削除してしまっていたのを戻しています。


Keep the comments in the generate application consistent

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

rails newで生成されるファイル内のコメントの末尾にピリオドを追加しています。


Merge PR #43141

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

mysql2 adapterでprepared_statementsが設定されていない場合、Rails 7.2ではデフォルト値がtrueに変わる旨メッセージを表示するよう修正しています。他のadapter(sqlite3、postgresql)ではデフォルトtrueになっており、挙動を合わせる為。


Merge PR #43295

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

SQLite adapterで、Rails 6.0で作成したreferences/belongs_toを使用したmigrationファイルをRails 6.1以降で実行すると生成されるスキーマが変わる(元々外部キーのカラムにintegerを使っていたのがbigintに変わってしまう)バグがあったのを修正しています。


Ruby 3.1: Handle Class#subclasses existing without Class#descendants

Active Supportの修正です。

Ruby 3.1で本体に含まれる予定だったClass#descendantsメソッドの本体への追加がRevertされました。しかし、Class#subclassesは予定通り追加されており、Ruby本体にClass#subclassesがある、しかし、Class#descendantsは無い、という状態でもそれぞれのメソッド、及び、DescendantsTrackerが動作するよう処理を修正しています。


Fix a mistake in DescendantsTracker#descendants for Ruby 3.1

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

DescendantsTracker#descendantsで変数名をタイポしていたのを修正しています。


Fix typo in #to_s deprecation in 7.0 release notes

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

#to_sメソッドをdeprecateにした対応について、参考リンクのフォーマットがおかしかったのを修正しています。