なるようになるブログ

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

rails commit log流し読み(2021/08/27)

2021/08/27分のコミットです。

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

activerecord/CHANGELOG.md


Make schema cache methods behave consistently

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

schema cache methods(columnscolumns_hashprimary_keysindexes)のtableが無かった場合の挙動に一貫性が無かったのを、どのadapterでも同じ挙動になるよう修正しています。


Eliminate some Integer() rescue nil patterns in Action Text

actiontext/lib/action_text/trix_attachment.rbの修正です。

Integer(xx) rescue nilInteger(xx, exception: false)に修正しています。


Fix changelog from #43105

activerecord/CHANGELOG.mdの修正です。

先のMake schema cache methods behave consistentlyの対応のCHANGELOGのエントリーに、各メソッドの挙動についての詳細な説明を追加しています。


Add ability to ignore tables in the schema cache

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

schema cacheに含みたくないtableを、config(config.active_record.schema_cache_ignored_tables)で指定出来るよう修正しています。

config.active_record.schema_cache_ignored_tables = ["ignored_table", "another_ignored_table"]

table名はRegexpでも指定出来るようになっています。

config.active_record.schema_cache_ignored_tables = [/^_/]

Updates guides CHANGELOG

guides/CHANGELOG.mdの修正です。

classic modeのautoloading guideを削除した対応、及び、 zeitwerk modeのautoloading guideを編集した対応についてエントリーを追加しています。


Updates railties CHANGELOG

railties/CHANGELOG.mdの修正です。

config.autoloader=を削除した対応についてエントリーを追加しています。


More railties CHANGELOG updates

railties/CHANGELOG.mdの修正です。

各autoloaderに関する対応についてのエントリーを追加しています。


Merge pull request #43097 from Shopify/ar-query-transformers

Active Recordの修正です。

ActiveRecord::QueryLogsについて、executeexec_queryメソッドそれぞれに対してhookを仕込んでいたのを修正しています。MySQL adapterでは1つのSQLの実行でexecuteexec_queryが両方が呼ばれる事があり、その為にコメントが既に追加済みかどうかのチェックが必要になってしまっていた為。また、hook処理をmoduleで追加するのも止めています。ユーザアプリケーション側で独自のadapterを保持している場合に正しく動作しない為。

rails commit log流し読み(2021/08/26)

2021/08/26分のコミットです。

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

activesupport/CHANGELOG.md

actionview/CHANGELOG.md


Merge pull request #43086 from nstuart-at-salesforce/nas_addRaiseErrorsParam

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

ActiveSupport::Cache::RedisCacheStore#handle_exception内のrescue blockを削除しています。rescue block内ではログの出力だけを行って、エラーの再throwは行われてなかったのですが、これだとエラーが発生した際にそれに気付けずよくないだろう、という事で単純に削除されています。


Avoid returning a constant in ActionDispatch::ShowExceptions

actionpack/lib/action_dispatch/middleware/show_exceptions.rbの修正です。

ActionDispatch::ShowExceptions#failsafe_responseでエラーレスポンスを返すのにconstantを使用していたのを、使用しないよ修正しています。レスポンスを動的に変更されてしまった場合にメッセージやHTTP statusが変わってしまう可能性がある為。


Iterates docs about autoloading during boot

rails guideのAutoloading and Reloading Constantsの修正です。

guide全体の言い回しの修正や、説明の追加等を行っています。


Replace webpack with importmapped Hotwire as default js (#42999)

railtiesの修正です。

RailsのデフォルトのJS設定がwebpackerからHotwire + Importmapに変更されました。webpackは--webpackerオプションを指定すれば引き続き使用出来る状態です。

諸々の詳細はModern web apps without JavaScript bundling or transpilingを参照。


Remove default reliance on Sass and CSS generators (#43110)

railtiesの修正です。

デフォルトではSass、及び、CSSに関するファイルの生成を行わないよう修正しています。今のWeb開発において手作業でmodel毎のCSSの開発は行わない事の方が多いだろう、というのと、Sassがdart-sassに移行してしまい、これをRailsで使用しようすると色々な依存が必要になってしまう為、デフォルトでは有効化しない事になりました。


Document that @rails/ujs is deprecated (#43112)

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

@rails/ujsはdeprecated(今後はTurbo + Stimulusが推奨)である旨ドキュメントに説明を追加しています。


Missed a generator assets spot

rails guideのThe Asset Pipelineの修正です。

デフォルトでは不要になったassetsの生成を無効化する方法についての説明を削除しています。


Merge pull request #43106 from flavorjones/flavorjones-activesupport-number-converter-valid-float

Action View、Active Supportの修正です。

ActionView::Helpers::NumberHelperActiveSupport::NumberHelperでFloatへの変換処理時にexception: false`オプションを指定するようにして、例外処理を行わないでよいよう修正しています。パフォーマンス改善の為。


Merge pull request #43098 from flavorjones/flavorjones-number-to-currency-detect-parse-failures

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

Fix number_to_currency to avoid negative format when displaying zero.の対応により、number_to_currency-0.0の戻り値が変わってしまっていたのを、修正前と同じ値を返すよう修正しています。

rails commit log流し読み(2021/08/25)

2021/08/25分のコミットです。

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

actionview/CHANGELOG.md


Copy-edit documentation [ci skip]

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

DB -> databaseに修正しています。


Make preload_link_tag work with images

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

preload_link_tagsvg以外の画像を指定した場合に、as attributeに適切な値が指定されるよう修正しています。


Clear up resolve_link_as

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

resolve_link_as内のif / elsifcase / whenを使用するよう修正しています。


Temporarily disable Azure service tests (#43091)

activestorage/test/test_helper.rbの修正です。

Azure serviceのテストを無効化しています。 API keyがexpireしたか何かでテストが通らない状態な為。


[GUIDES] Fix ActiveJob custom serializer typo

rails guideのActive Job BasicsAutoloading and Reloading Constantsの修正です。

initializerのファイル名のパスにタイポがあったのを修正しています。


[ci skip] Use symbols and double quoted strings more consistently in these docs

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

exampleコード内のsingle quoteをdouble quoteに修正、及び、Symbolを使える箇所をSymbolを使うよう修正しています。


[ci skip] Fix some links that didn't link but now should, you get me?

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

オプションについて説明をしている箇所のフォーマットが崩れていたのを修正しています。


[ci skip] Modernize example; make it consistent with the example at the top documentation

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

FormOptionsHelperのdoc内の言い回しの修正や、exampleコードのフォーマットの修正等を行っています。


[ci skip] Use more modern tag.x call structure

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

exampleコードでnestしたHTMLを生成するのにcontent_tagを使用していたのを、tagメソッドを使用するよう修正しています。


[ci skip] Use more consistent spacing; trim some ending newlines

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

不要な空行の削除、exampleコード内の適切な位置に改行の追加等を行っています。


[ci skip] Fully qualify attributes (we're in docs) and move them above the class so it's not confused with the belongs_to's

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

exampleコードでclassが想定しているattributeの説明をclassの前に説明するよう修正しています。

rails commit log流し読み(2021/08/24)

2021/08/24分のコミットです。

CHANGELOGへの追加はありませんでした。


Move AS::Dependencies.clear to the main file

Active Supportの修正です。

activesupport/lib/active_support/dependencies/zeitwerk_integration.rbに定義してあったActiveSupport:::Dependencies.clearメソッドをactivesupport/lib/active_support/dependencies/zeitwerk_integration.rbに移動しています。


Merge pull request #42945 from jhawthorn/hash_match

Action Viewの修正です。

template cacheの管理に "details key"をベースにしたcache(key毎に異なるhashを持ち、それらを比較しチェックする)をやめて、Encapsulate "details" into TemplateDetailsで追加したTemplateDetailsを使用したhashによる管理で行うよう修正しています。比較するhashの回数が減り、パフォーマンス向上が見込まれる為。


Add require to failing multi_db test

railties/test/application/rake/multi_dbs_test.rbの修正です。

classic autoloaderを削除後、multi dbのテストがfailするようになっていたのを修正しています。


Add a test to catch regressions for render_to_string to not override subsequent render

Action Viewのテストの修正です。

render_to_stringの後にrenderを実施する場合のテストを追加しています。


Upgrade azure-storage-blob to use at least 2.0.0

azure-storage-blobのバージョン指定を"~> 2.0"に修正しています。azure-storage-blob 1系はRuby 2.5までしかサポートしておらず、現在のRailsがサポートしているRubyのバージョン的に、azure-storage-blob 2系が必須な為。


Merge pull request #43079 from Shopify/ar-query-logs-instance-exec

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

ActiveRecord::QueryLogsのtag処理内でActiveRecord::QueryLogsを参照するのにinstance_execを使用していたのを、tagのblockの引数として渡すよう修正しています。


Handle NullObject instances in Active Job query tag

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

Active Job query tagでcontextがNullObjectの場合のガード処理を追加しています。


Look yarnpkg in $PATH other than yarn (#42253)

railties/lib/rails/generators/rails/app/templates/bin/yarn.ttの修正です。

yarnを実行するコマンドを検索する際に、yarnpkgも検索対象にするよう修正しています。Debianではyarnpkg packageが提供されており、そのpackageを使えるようにする為。

rails commit log流し読み(2021/08/23)

2021/08/23分のコミットです。

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

activerecord/CHANGELOG.md


Don't use redundant curly braces in where examples [ci-skip]

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

Hashを定義するのに不要な波括弧を使用している箇所があったのを修正しています。


Namespace fixture classes in this test

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

テスト用のクラスをtop-levelに定義していたのを、テスト用のmoduleを定義し、その下に定義するよう修正しています。


Remove autoloading logic from AS::DescendantsTracker

Active Supportの修正です。

ActiveSupport::DescendantsTrackerからautoloadingに関する処理を削除しています。autoloadingは使用する側の責務で、ActiveSupport::DescendantsTrackerで対応すべき内容ではない為。


Deletes spurious spaces

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

不要なスペースを削除しています。


Delete AS::Dependencies.autoloaded?

Active Supportの修正です。

Remove autoloading logic from AS::DescendantsTrackerにより不要になたActiveSupport::Dependencies.autoloaded?メソッド、及び、関連メソッドを削除しています。


Delete the classic version of AS::Dependencies.autoloaded_constants

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

classic loader削除に伴い不要になったActiveSupport::Dependencies.autoloaded_constantsを削除しています。


Delete the classic version of AS::Dependencies.clear

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

classic loader削除に伴い不要になったActiveSupport::Dependencies.clearを削除しています。


AS::Dependencies no longer extends self

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

ActiveSupport::Dependenciesextend selfを削除しています。mixinとして使われる事はもう無い筈の為。


Delete private constant AS::Dependencies::UNBOUND_METHOD_MODULE_NAME

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

classic loader削除に伴い不要になったActiveSupport::Dependencies::UNBOUND_METHOD_MODULE_NAMEを削除しています。


Delete AS::Dependencies.autoloaded_constants

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

classic loader削除に伴い不要になったActiveSupport::Dependencies.autoloaded_constantsを削除しています。


Delete AS::Dependencies.verbose=

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

ActiveSupport::Dependencies.verbose=を削除しています。autoloadingのactivityを出力するには、Rails.autoloaders.log!を使用するのが推奨されており、verboseを直接設定する事は無い為。


Merge pull request #43050 from intrip/42912-restore-db-connection-on-schema-load-name

activerecord/lib/active_record/railties/databases.rakeの修正です。

db:schema:load:nameで複数DB向けの処理を行った後に、コネクションを元の接続先に戻すよう修正しています。


Make ActiveRecord::QueryLogs default behavior to return the context content

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

ActiveRecord::QueryLogsがデフォルトでcontextの値を返すよう修正しています。下記のようなユースケースに対応出来るようにする為。

config.active_record.query_log_tags = [:api_client_id]

ActiveRecord::QueryLogs.set_context(api_client_id: api_client.id) do
  # ...
end

Make QueryLogs.set_context restore previous values

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

ActiveRecord::QueryLogs.set_contextにblockを指定した場合に、blockの処理終了後にcontextを処理終了前の状態に戻すよう修正しています。他のAPIと挙動を合わせる為。

rails commit log流し読み(2021/08/22)

2021/08/22分のコミットです。

CHANGELOGへの追加はありませんでした。


Let the Action Pack autoload with Zeitwerk

Action Packのテストの修正です。

autoloadをするのにZeitwerkを使用するよう修正しています。


[GUIDES]: Fix ActiveStorage::FixtureSet.blob YAML

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

fixtureのファイルパスを、アプリケーションルートからの相対パスに修正、及び、シンタックスハイライトが効くよう、複数行のメソッド呼び出しを1行で行うよう修正しています。


Restore autoloading test for STI

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

Deletes classic test related to STIで削除したテストを戻す&Zeitwerkを使用するよう修正しています。autoloadに関するテストは本来各コンポーネントにあるべきではない(railtiesで行うべき)と思われるが、コンポーネント内にあった方がわかりやすいのでは、という事で戻したようです


Restore AJ autoloading test

activejob/test/cases/test_helper_test.rbの修正です。

Deletes an AJ test that used classicで削除したテストを戻す&Zeitwerkを使用するよう修正しています。autoloadに関するテストは本来各コンポーネントにあるべきではない(railtiesで行うべき)と思われるが、コンポーネント内にあった方がわかりやすいのでは、という事で戻したようです


Delete extra empty line

activejob/test/jobs/queue_adapter_job.rbの修正です。

ファイル末尾の空行を削除しています。

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

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

CHANGELOGへの追加はありませんでした。


Delete AS::Dependencies.safe_constantize

Active Supportの修正です。

classic loader削除に伴い不要になったActiveSupport::Dependencies.safe_constantizeメソッドを削除しています。


Depends on Zeitwerk 2.5.0.beta2

activesupport/activesupport.gemspecの修正です。

Zeitwerkを2.5.0.beta2に更新しています。


Update Gemfile.lock

Gemfile.lockの修正です。

先のZeitwerkの更新の際にGemfile.lockの更新が漏れていたのを対応しています。