なるようになるブログ

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

rails commit log流し読み(2024/04/23)

2024/04/23分のコミットです。

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

activesupport/CHANGELOG.md


Deprecate ActiveSupport::ProxyObject

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

ActiveSupport::ProxyObjectをdeprecatedにしています。Ruby本体のBasicObjectが無かった頃に必要だったクラスで、現在はBasicObjectを使えばよくなっているため。


Let Action Cable's autoloader ignore the version file

actioncable/lib/action_cable.rbの修正です。

Action Cable用のautoloaderでversion.rbをignoreするよう修正しています。version.rbgem_version.rbに依存している、かつ、gem_version.rbは既にignoreされており、version.rbだけ単体でロードされても動作しないため。


Use Module#include rather than prepend since we don't need prepend semantics here and include leads to faster method lookups.

activesupport/lib/active_support/core_ext/numeric/conversions.rbactivesupport/lib/active_support/core_ext/object/json.rbの修正です。

Module#prependを使っている箇所で、Module#includeで良い箇所についてはModule#includeを使用するよう修正しています。Module#includeの方がmethod lookupが速いため。


Fix ActionView backtrace filtering on Ruby 3.4+

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

backtraceのfilter処理で、Ruby 3.4で変更になったbacktraceのフォーマット(backtickを使用しないよう修正)をサポートするよう修正しています。


Merge pull request #51271 from sato11/enable-compact-blank

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

不足していたrequireを追加しています。


Merge pull request #50780 from zachasme/app-update-skip-sprockets

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

app:updateを実行する際に、Sprocketsが使われているかPropshaftが使われているかどうかをチェックし、生成するファイルを変更するよう修正しています。


Ensure pre-7.1 migrations use legacy index names when using rename_table

Active Recordの修正です。

Rails 7.1より前で作られたmigrationファイル内でrename_tableを使っていた場合に、rename_tableで作られるindex名がRails 7.1で対応された新しいindex名になってしまうバグがあったのを修正しています。


Support hexBinary format in XML

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

ActiveSupport::XmlMinihexBinaryエンコードされたファイルのパースをサポートするよう修正しています。


Rename method to keep it consistent with others parse* versions

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

hexBinary用のパースメソッドのメソッド名を_からはじめるよう修正しています。他のメソッド名と名前を合わせる為。


Merge pull request #51635 from silva96/patch-2

railties/lib/rails/generators/migration.rbのdocの修正です。

Rails::Generators::Migration moduleのdocについて、フォーマットや言い回しの修正を行っています。


Join association built from string join should not retry

activerecord/lib/active_record/associations/join_dependency/join_association.rbの修正です。

ユーザが指定した文字列でのjoin処理ではqueryのretryは行わないよう修正しています。


Update guides: Replace filter with action callback

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

actionのcallback処理について説明している箇所で、古い"filter"という言い方をしている箇所があったのを、"action callback"に修正しています。

rails commit log流し読み(2024/04/22)

2024/04/22分のコミットです。

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


Fix ActiveSupport configurations deprecations

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

Active Supportでdeprecatedになったconfig名のチェック処理が正しく行えてなかったのを修正しています。


Merge pull request #51620 from joshuay03/encourage-lease-connection-on-model-inspect-no-connection

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

ActiveRecord::Core#inspectメソッドで、DBに接続していない場合に表示する接続用のメソッド名をconnectionからlease_connectionに変更しています。ActiveRecord::Base.connectionはsoft deprecatedになっている為。


SerializedAttributeTest: use decorate_attribute

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

decorated typeに関するテストで、テスト対象のメソッドが誤っていたのを修正しています。


Update comments for helper method generation

actionpack/lib/abstract_controller/helpers.rbactionview/lib/action_view/test_case.rbの修正です。

helper methodを生成するmethod内のコメントが、実際に生成されるmethodと異なる内容になっていたのを修正しています。


Update builder doc links to point to the rails repo [ci skip]

docの修正です。

https://github.com/jimweirich/builderへのリンクをhttps://github.com/rails/builderに修正しています。現在はrails配下のforkしたリポジトリが使用されている為。


Remove reference to BlankSlate

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

現在は存在しないbuilder gemのBlankSlate classについて言及している箇所があったのを修正しています。

rails commit log流し読み(2024/04/20)

2024/04/20分のコミットです。

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

actionpack/CHANGELOG.md


[Fix #51095] Missing template error page showing incorrect view path example for nested controller path

actionpack/lib/action_dispatch/middleware/templates/rescues/missing_exact_template.html.erbの修正です。

templateが見つからない場合に表示するエラー用のHTMLで、controller pathがnestしている場合に正しいtemplate名が表示されないバグがあったのを修正しています。


Refactor code to make it more clear

activerecord/lib/arel/visitors/to_sql.rbの修正です。

SQLを生成する際に括弧が必要になる条件のチェックをメソッドに切り出すようリファクタリングしています。


Merge pull request #50856 from Dmoment/docs-autosave-validations

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

has_oneメソッドのdocに、autosave`をtrueにしている場合のvalidationの挙動についての説明を追加しています。


Copy edit documentation

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

has_one`メソッドのdocのフォーマットの修正を行っています。


docs: Fix ActiveSupport::TimeWithZone#change example [skip ci]

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

ActiveSupport::TimeWithZone#changeメソッドのdoc内のexampleコードの実行結果が、実際の結果と異なっていたのを修正しています。

rails commit log流し読み(2024/04/19)

2024/04/19分のコミットです。

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

actionpack/CHANGELOG.md

activerecord/CHANGELOG.md


Add print styles to Rails guides (#51458)

rails guideの修正です。

印刷用のCSS が全体のCSSよりインラインになるように修正しています。


Merge pull request #51588 from duduribeiro/add-devcontainer-forward-ports

railties/lib/rails/generators/devcontainer.rbrailties/lib/rails/generators/rails/app/templates/.devcontainer/devcontainer.json.ttの修正です。

rails newで生成するdevcontainer.jsonで、forward portsを使用するよう修正しています。forward portsを自動で行ってくれない環境でもDevcontainerにアクセス出来るようにするため。


Merge pull request #51479 from nhorton/patch-5

actionpack/lib/action_dispatch/system_testing/driver.rbの修正です。

driven_byでremote browserを指定するよう設定している場合に、browserのpreload処理が出来ずロード時にエラーになってしまうバグがあったのを修正しています。


Merge pull request #50826 from hexdevs/ta/document-in-order-of-with-enum

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

ActiveRecord::QueryMethods#in_order_ofenumnilを指定した場合のexampleを追加しています。


test: update karma npm from 3.1.4 to 6.4.2

actioncable/package.jsonの修正です。

karma npmのバージョンを最新バージョンに更新しています。


Merge pull request #49774 from stevepolitodesign/sp-disable-inheritance

docの修正です。

rails guide及びinheritance_columnのdocにinheritance columnのオーバーライド、及び、無効化についての方法の説明を追加しています。


Add save_and_open_page helper to IntegrationTest

Action Packの修正です。

IntegrationTestでsave_and_open_pageメソッドを使用出来るよう対応しています。IntegrationTestの場合、レスポンスをファイルに保存し、それをブラウザで開く(オープン処理はcopiousfreetime/launchy gemを使用)よう対応されています。


Merge pull request #51036 from zzak/railties/asto-integration

railties/test/application/active_storage/uploads_integration_test.rbの修正です。

Active Storageのfile upload処理のintegrationテストを追加しています。


Don't silently execute statements on migrations when they can't be reversed

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

migrationファイル内でupdateメソッドを使用している場合に、そのmigrationをrevertした際に、updateメソッドが暗黙的に実行されてしまうバグがあったのを修正しています。

が、修正内容に問題があったため、後ほどRevertされています。


Remove unused variable assignment in test

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

使用していない変数を削除しています。


Action View Tests: Use #with_routing helper

actionview/test/abstract_unit.rbactionview/test/actionpack/controller/view_paths_test.rbの修正です。

Action Viewのテストで、Make with_routing test helper work for integration testsで追加されたwith_routing helperを使うよう修正しています。


Revert "Don't silently execute statements on migrations when they can't be reversed"

そのmigrationをrevertした際に、migration内のupdateメソッドが暗黙的に実行されてしまうバグがあったのを修正した、Don't silently execute statements on migrations when they can't be re…をRevertしています。修正というより既存の挙動を変更してしまう対応だったため。


Strict loading using :n_plus_one_only does not eagerly load child associations.

activerecord/lib/active_record/associations/collection_association.rbactiverecord/lib/active_record/core.rbの修正です。

strict_loading:n_plus_one_onlyオプションを指定していた場合に、指定したmodelの子associationをfirstlastでloadした場合にActiveRecord::StrictLoadingViolationErrorがraiseされてしまうバグがあったのを修正しています。


Fix some more ignored block warnings

blockを使用していないメソッドにblockを渡していた箇所があったのを、blockを渡さないよう修正しています。


Arel: only wrap SELECT statements in UNION if they involve ORDER BY, LIMIT or OFFSET

activerecord/lib/arel/visitors/to_sql.rbの修正です。

ArelでUNIQO用のSQLを生成する際にSELECTを括弧で括るようFixes/union select parenthesesで修正したのですが、、括らないよう戻しています。SQLiteでエラーになるSQLが生成されるようになってしまった為。


Fix indentation on save_and_open_page tests

actionpack/test/controller/integration_test.rbの修正です

save_and_open_pageメソッドのテストのインデントを修正しています。


Fix typo in page_dump_helper.rb

actionpack/lib/action_dispatch/testing/test_helpers/page_dump_helper.rbの修正です。

defaultdefaulにタイポしていたのを修正しています。

rails commit log流し読み(2024/04/18)

2024/04/18分のコミットです。

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

actionpack/CHANGELOG.md

activerecord/CHANGELOG.md


Merge pull request #51523 from etiennebarrie/route-to-implicit-controller

actionpack/lib/action_dispatch/routing/mapper.rbの修正です。

Rails 7.1.3で、routeでcontroller scope無いでtoオプションをcontrollerの指定無しで定義した場合にエラーになるリグレッションが発生していたのを修正しています。

Rails.application.routes.draw do
  controller :home do
    get "recent", to: "recent_posts"
  end
end

Merge pull request #51445 from shouichi/remove-node-modules-from-the-final-image

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

Dockerの最終imageに不要にnode_modulesを含まないよう修正しています。


Merge pull request #51440 from CodingItWrong/libmysql2-fix-install-error

Gemfile.lockの修正です。

mysql2 gemを最新バージョンに更新しています。mysql-client 8.3で動作するようにするため。


Pin sqlite3 version in bug_report_templates

bug report templatesの修正です。

sqlite3 gemのバージョンを1系にロックしています。最新の2系だとbundlerでのロード時にエラーになってしまうため。


Correct typo for ActiveJob::Enqueuing::ClassMethods doc

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

ActiveJob::Enqueuing::ClassMethods moduleのdoc内のタイポを修正しています。


Allow sqlite3 to float to version 2

activerecord/lib/active_record/connection_adapters/sqlite3_adapter.rbrailties/lib/rails/generators/database.rbの修正です。

sqlite3 gemの2系を使用出来るよう、コード内のgemのバージョン指定を修正しています。


Fix unused block warnings for template methods

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

blockを使用していないメソッドにblockを渡さないよう修正しています。


Remove outdated mathn related test

mathn gemがロードされている場合の為のテストを削除しています。mathn gemはRuby本体から削除済み、かつ、gemとしてもdeprecatedになっており、考慮する必要がなくなっている為。


Action View Caching code sample syntax [ci skip]

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

ActionView::CacheHelper.cacheメソッドのdoc内のexampleコードで内のコメント部分の先頭に#を追加し、コメントである事がわかるよう修正しています。

rails commit log流し読み(2024/04/17)

2024/04/17分のコミットです。

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


Merge pull request #51572 from Bodacious/patch-1

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

RubyVM::YJITがenableかどうかのチェックを括弧で括るよう修正しています。チェックに&&等の条件を独自に追加した場合にチェックが動作するようにするため。


test: fix flaky schema dump test to prefer YAML to Marshal

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

schema dumpのテストで使用するファイルのフォーマットをMarshalからYAMLに変更しています。Marshalの場合、ファイルの中身が完全に毎回同じ内容になる事を保証しておらず、時折テストが失敗してしまうため。


Merge pull request #51476 from marvinthepa/no_anonymous_block_parameter

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

古いRubyno anonymous block parameterでエラーになるコードがあったのを修正しています。


ruby-head: handle unused block warnings

activesupport/lib/active_support/testing/strict_warnings.rbactivesupport/test/time_travel_test.rbの修正です。

Ruby 3.4でblockを使用していないメソッドにblockを渡した場合にwarningが出るようになるのですが、そのwarningについては発生してもテストをfailしないよう修正しています。false positiveが少しあるようで、まだ微調整中と思われる為。

参考:Feature #15554: warn/error passing a block to a method which never use a block


TestCase#create_fixtures no longer takes a block

Active Recordのテストの修正です。

ActiveRecord::FixtureSet.create_fixturesメソッドにうけつけていないblockを渡している箇所があったのを修正しています。