なるようになるブログ

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

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

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

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


[ci skip]Add a missing double quote on code comments

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

ActiveSupport::ErrorReporterのdoc内のexampleコードで、クォートが不足している箇所があったのを修正しています。


Merge pull request #43623 from jcoyne/guide

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

JavaScript compressionについて説明している箇所からuglifierを削除しています。uglifierはES5でしか動作せず、現在は推奨されてない為。


Merge pull request #43671 from Shopify/as-use-isolated-state

Active Supportの修正です。

Threadを使用していた箇所を、Introduce ActiveSupport::IsolatedExecutionState for internal useで追加したActiveSupport::IsolatedExecutionStateを使用するよう修正しています。


Merge pull request #43674 from Shopify/activerecord-isolated-state

Active Recordの修正です。

Threadを使用していた箇所を、Introduce ActiveSupport::IsolatedExecutionState for internal useで追加したActiveSupport::IsolatedExecutionStateを使用するよう修正しています。


Eliminate internal uses of PerThreadRegistry and deprecate it

ActiveSupport::PerThreadRegistryを使用して箇所を、ActiveSupport::IsolatedExecutionStateを使用するよう修正、及び、もう不要になったActiveSupport::PerThreadRegistryをdeprecateにしています


Fix Typo in actio_controller::params_wrapper

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

ActionController::ParamsWrapperのdoc内のグラマーの修正を行っています。


Improve check for GC.stat(:total_allocated_objects)

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

GC.stat(:total_allocated_objects)を使用出来るかどうかをexceptionが発生するかどうかでチェックしていたのを、GC.stat.key?(:total_allocated_objects)でチェックするよう修正しています。

rails commit log流し読み(2021/11/20)

2021/11/20分のコミットです。

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

activerecord/CHANGELOG.md

activesupport/CHANGELOG.md


Merge pull request #43625 from Shopify/error-reporting-api

Active Support、railtiesの修正です。

error reporting処理の為のActiveSupport::ErrorReporter classを追加しています。Railsのerror reporting処理がRailsの中で統一されてなくて、それを統一する為の対応。

ActiveSupport::ErrorReporterにはerror発生時に処理をおこなう為のsubscriberを登録する事ができるようになっています。また、subscriberはreport(Exception, handled: Boolean, context: Hash)メソッドが定義されている必要がります。

ActiveSupport::ErrorReporterはerrorが発生した際に、subscriberを呼び出しで処理を継続するhandleメソッドと、subscriberを呼び出して処理を停止するrecordメソッドがそれぞれpublic APIとして提供されています。また、ActiveSupport::ErrorReporterはshort handとして、Rails.errorで使用出来るようになっています。

Rollback transactions when the block returns earlier than expected

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

deprecatedになっていた、transaction block内でreturnbreakthrowを使用した場合、transactionがcommitされて終了する、という振る舞いを削除しています。今後は、rollbackされるようになります。


Remove deprecated DatabaseConfig#config method

activerecord/lib/active_record/database_configurations/database_config.rbactiverecord/lib/active_record/database_configurations/hash_config.rbの修正です。

deprecatedになっていたDatabaseConfig#configメソッドを削除しています。


Remove deprecated rake tasks: activerecord/lib/active_record/railties/databases.rakeの修正です。

deprecatedになっていたdb:xx等のrake taskを削除しています。


Remove deprecation for aggregations that are grouping in duplicated fields

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

deprecatedになっていた、aggregations + groupした場合に同じfieldsが複数生成されてしまう、という挙動を削除しています。


Remove deprecated support to Model.reorder(nil).first to search using non-deterministic order.

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

deprecatedになっていた、reorder(nil) + first / first!を使用した場合に実行されるSQLORDERが指定されない、という挙動が削除されました。今後はreorder(nil)が指定されていてもORDERが指定されるようなっています。


Remove code duplication by moving logic to check_if_method_has_arguments!

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

重複して行われていたargsの展開・空の値の削除処理を削除しています。


Remove deprecation for duplicated query annotations

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

deprecatedになっていた、aggregations + annotateした場合に同じfieldsが複数生成されてしまう、という挙動を削除しています。


Change how Merging conditions on the same column works

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

deprecatedになっていた、同じカラムに対するmergeで両方の条件を保持する、という挙動を削除して、後者の条件で処理が行われるようにしています。

# Rails 6.1
Author.where(id: [david.id, mary.id]).merge(Author.where(id: bob)) # => [bob]
Author.where(id: david.id..mary.id).merge(Author.where(id: bob)) # => []
Author.where(id: david.id..mary.id).merge(Author.where(id: bob), rewhere: true) # => [bob]


# Rails 7.0
Author.where(id: [david.id, mary.id]).merge(Author.where(id: bob)) # => [bob]
Author.where(id: david.id..mary.id).merge(Author.where(id: bob)) # => [bob]

Remove deprecated environment and name arguments from Tasks::DatabaseTasks.schema_up_to_date?

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

deprecatedになっていた、Tasks::DatabaseTasks.schema_up_to_date?environmentname引数を削除しています。


Remove deprecated methods in `Tasks::DatabaseTasks

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

deprecatedになっていたTask::DatabaseTasksの各メソッドを削除しています。合わせて、使われなくなったTasks::DatabaseTasks.schema_file_typeをdeprecateにしています。


Remove deprecated config.active_support.use_sha1_digests

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

deprecatedになっていたconfg.active_support.use_sha1_digestsを削除しています。


Remove deprecated URI.parser

activesupport/lib/active_support/core_ext.rbactivesupport/lib/active_support/core_ext/uri.rbの修正です。

deprecatedになっていたURI.parserを削除しています。


Remove deprecated support to use Range#include? to check the inclusion of a value in a date time range is deprecated

activesupport/lib/active_support/core_ext/range/include_time_with_zone.rbの修正です。

deprecatedになっていた、Range#include?でのdate time rangeに値が含まれているかをチェックする挙動を削除しています。


Merge pull request #43421 from seanpdoyle/action-view-unify-form-implementation

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

form_forメソッドでform_withを再利用するよう修正しています。


Merge PR #42006

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

ActiveRecord::Base.filter_attributesで指定されたattributeについて、SQL queryのlogでもfilter処理が行われるようする修正しています。

# Before:
# => Foo Load (0.2ms)  SELECT "foos".* FROM "foos" WHERE "foos"."passw" = ? LIMIT ?  [["passw", "hello"], ["LIMIT", 1]]

# After:
# => Foo Load (0.5ms)  SELECT "foos".* FROM "foos" WHERE "foos"."passw" = ? LIMIT ?  [["passw", "[FILTERED]"], ["LIMIT", 1]]

Merge pull request #43045 from sandip-mane/array-syntax-consistancy

activestorage/db/migrate/20170806125915_create_active_storage_tables.rbの修正です。

Arrayの指定方法に、他の箇所と合わせるよう修正しています。


Remove deprecate ActiveSupport::Multibyte::Unicode.default_normalization_form

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

deprecatedになっていたActiveSupport::Multibyte::Unicode.default_normalization_formを削除しています。


Remove deprecated :return_false_on_aborted_enqueue option

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

deprecatedになっていたActiveJob.return_false_on_aborted_enqueueを削除しています。


Remove duplicated tests

activemodel/test/cases/errors_test.rbの修正です。

重複していたテストを削除しています。


Remove deprecated ActiveRecord::Base.connection_config

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

deprecatedになっていたActiveRecord::Base.connection_configを削除しています。


Remove deprecated ActiveRecord::Base.arel_attribute

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

deprecatedになっていたActiveRecord::Base.arel_attributeを削除しています。


Remove deprecated ActiveRecord::Base.configurations.default_hash.

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

deprecatedになっていたActiveRecord::Base.configurations.default_hashを削除しています。


Remove deprecated ActiveRecord::Base.configurations.to_h

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

deprecatedになっていたActiveRecord::Base.configurations.to_hを削除しています。


Fix typo

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

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


Remove deprecated ActiveRecord::Result#map! and ActiveRecord::Result#collect!

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

deprecatedになっていたActiveRecord::Result#map!ActiveRecord::Result#collect!を削除しています。


Merge pull request #43675 from esparta/fix_race_conditions_test_cache_ii

activesupport/test/cache/behaviors/cache_store_behavior.rbactivesupport/test/cache/behaviors/cache_store_version_behavior.rbの修正です。

Active Supportのcacheのテストで、異なるテストで同じkeyを使っていた為に並列に実行するとランダムにfailしてしまっていたのを、keyにランダムな値を使用するようにして、並列に実行してもfailしないよう修正しています。


Fix typo

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

EncryptedAttributeType#initializeメソッドのdoc内のタイポを修正しています。

rails commit log流し読み(2021/11/19)

2021/11/19分のコミットです。

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


Remove unnecessary require

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

不要なrequireを削除しています。


Remove unnecessary paths

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

classのautoloadに対して不要なpathの指定が行われていたのを削除しています。


Sort autoloads

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

autoloadの指定を名前順に並び替えています。


Fix TestFixtures autoload

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

TestFixturesのautoloadに対してpathの指定を追加しています。


Fix some race conditions on ActiveSupport cache test

activesupport/test/cache/behaviors/cache_increment_decrement_behavior.rbactivesupport/test/cache/behaviors/cache_store_behavior.rbの修正です。

Active Supportのcacheのテストで、異なるテストで同じkeyを使っていた為に並列に実行するとランダムにfailしてしまっていたのを、keyにランダムな値を使用するようにして、並列に実行してもfailしないよう修正しています。

rails commit log流し読み(2021/11/18)

2021/11/18分のコミットです。

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

actionmailbox/CHANGELOG.md

actionmailer/CHANGELOG.md

actionpack/CHANGELOG.md

activejob/CHANGELOG.md

activemodel/CHANGELOG.md

activerecord/CHANGELOG.md


Fix spelling of Additionally

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

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


Merge pull request #43636 from TooManyBees/fix-preloader-association-nil-error

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

preloaderのrecordsにnilを指定した場合にNoMethodErrorが発生してしまうリグレッションがあったのを修正しています。

が、この対応によりCIが壊れてしまったので、後ほどRevertされています。


Revert "Merge pull request #43636 from TooManyBees/fix-preloader-association-nil-error"

直前の、preloaderのrecordsにnilを指定した場合にNoMethodErrorが発生してしまうリグレッションがあったのを修正した対応をRevertしています。CIが壊れてしまった為。


Remove deprecated MAILGUN_INGRESS_API_KEY and mailgun_api_key configurations

actionmailbox/app/controllers/action_mailbox/ingresses/mailgun/inbound_emails_controller.rbの修正です。

deprecatedになっていたMAILGUN_INGRESS_API_KEY envのサポート、及び、Rails.application.credentials.action_mailbox.mailgun_api_keyを削除しています。


Remove deprecated ActionMailer::DeliveryJob and ActionMailer::Parameterized::DeliveryJob

Action Mailerの修正です。

deprecatedになっていたActionMailer::DeliveryJobActionMailer::Parameterized::DeliveryJobを削除しています。


Remove deprecated ActionDispatch::Response.return_only_media_type_on_content_type.

actionpack/lib/action_dispatch/http/response.rbの修正です。

deprecatedになっていたActionDispatch::Response.return_only_media_type_on_content_typeを削除しています。


Remove deprecated Rails.config.action_dispatch.hosts_response_app

actionpack/lib/action_dispatch/middleware/host_authorization.rbrailties/lib/rails/application/default_middleware_stack.rbの修正です。

deprecatedになっていたRails.config.action_dispatch.hosts_response_appを削除しています。


Remove deprecated ActionDispatch::SystemTestCase#host!

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

deprecatedになっていたActionDispatch::SystemTestCase#host!を削除しています。


Remove deprecated support to passing a path to fixture_file_upload relative to fixture_path

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

deprecatedになっていたfixture_file_uploadfixture_pathからの相対パスを指定した場合のサポートを削除しています。


Remove deprecated Rails.config.action_view.raise_on_missing_translations

Action Viewの修正です。

deprecatedになっていたRails.config.action_view.raise_on_missing_translationsを削除しています。


Removed deprecated behavior that was not halting after_enqueue/after_perform callbacks when a previous callback was halted with throw :abort.

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

deprecatedになっていた、after_enqueue / after_perform callbacksで前のcallbackがthrow :abortで終了した場合も処理を継続する、という挙動を削除しています。合わせて、この挙動を制御する為のconfig(Rails.config.active_job.skip_after_callbacks_if_terminated)をdeprecatedにしています。


Remove deprecated enumeration of ActiveModel::Errors instances as a Hash

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

deprecatedになっていたActiveModel::Errorsのenumeration処理でインスタンスHashとして扱う挙動を削除しています。


Remove deprecated ActiveModel::Errors#to_h

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

deprecatedになっていたActiveModel::Errors#to_hを削除しています。


Remove deprecated ActiveModel::Errors#slice!

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

deprecatedになっていたActiveModel::Errors#slice!を削除しています。


Remove deprecated ActiveModel::Errors#values

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

deprecatedになっていたActiveModel::Errors#valuesを削除しています。


Remove deprecated ActiveModel::Errors#keys

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

deprecatedになっていたActiveModel::Errors#keysを削除しています。


Remove deprecated ActiveModel::Errors#to_xml

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

deprecatedになっていたActiveModel::Errors#to_xmlを削除しています。


Remove unused method

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

上記deprecatedメソッドの削除により不要になったメソッドを削除しています。


Remove deprecated support concat errors to ActiveModel::Errors#messages

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

deprecatedになっていたActiveModel::Errors#messagesに対するエラーメッセージのconcat処理を削除しています。


Remove deprecated support clear errors from ActiveModel::Errors#messages

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

deprecatedになっていたActiveModel::Errors#messagesに対するerrorsのclear処理を削除しています。


Remove unnecessary class

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

不要になったdeprecated処理の為のクラスを削除しています。


Implement each using a delegator and make sure all enumerable methods are available

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

ActiveModel::Errors#eachメソッドを独自に定義してたのを、他のenumerableメソッドと同様にdelegatorを使用するよう修正しています。deprecatedになっていた既存の挙動を削除することにより、独自のメソッドを定義する必要が無くなった為。


Remove deprecated support delete errors from ActiveModel::Errors#messages

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

deprecatedになっていたActiveModel::Errors#messagesに対するerrorsのdelete処理を削除しています。


Remove deprecated support to use []= in ActiveModel::Errors#messages

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

deprecatedになっていたActiveModel::Errors#messagesに対する[]=メソッドを削除しています。


Remove support to Marshal and YAML load Rails 5.x error format

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

Rails 5系のコードで作成されたActiveModel::ErrorsインスタンスのMarshal、 YAMLデータのロード処理のサポートを削除しています。


Remove support to Marshal load Rails 5.x ActiveModel::AttributeSet format

activemodel/lib/active_model/attribute_set/builder.rbの修正です。

Rails 5系のコードで作成されたActiveModel::AttributeSetインスタンスのMarshalデータのロード処理のサポートを削除しています。


Remove deprecated ActiveRecord::Base.allow_unsafe_raw_sql

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

deprecatedになっていたActiveRecord::Base.allow_unsafe_raw_sqlを削除しています。


Remove deprecated option :spec_name in the configs_for method

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

deprecatedになっていたconfigs_forメソッドの:spec_name引数を削除しています。


Remove deprecated support to YAML load ActiveRecord::Base instance in the Rails 4.2 and 4.1 formats

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

Rails 4.1、及び、4.2のコードで作成されたActiveRecord::BaseインスタンスYAMLデータのロード処理のサポートを削除しています。


Remove deprecation warning when using :interval column is used in PostgreSQL database

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

deprecatedになっていたPostgreSQLinterval datatypeをStringとして扱う処理を削除しています。今後は、ActiveSupport::Durationとして扱われるようになります。


Remove deprecated private API in ActiveRecord::Associations::Preloader

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

deprecacatedになっていたActiveRecord::Associations::PreloaderAPIを削除しています。private APIなのでCHANGELOGはなし。


Remove deprecacated support to resolve connection using "primary" as connection specification name

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

deprecatedになっていたconnection specification nameにprimaryという値を指定した場合の挙動を削除しています。


Remove deprecated support to quote ActiveRecord::Base objects

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

deprecatedになっていた#quoteメソッドにActiveRecord::Baseインスタンスを渡した場合の挙動を削除しています。


Remove deprecated support to type cast to database values ActiveRecord::Base objects

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

deprecatedになっていた#type_castメソッドにActiveRecord::Baseインスタンスを渡した場合の挙動を削除しています。


Remove deprecated support to pass a column to type_cast

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

deprecatedになっていた#type_castメソッドにcolumnを渡した場合の挙動を削除しています。


Inline _quote method

Active Recordの修正です。

quoteメソッドが_quoteメソッドを呼び出すだけになっていたのを、quote_quoteで行っていた処理を行うようにして、_quoteを削除するよう修正しています。


Inline _type_cast

Active Recordの修正です。

type_castメソッドが_type_castメソッドを呼び出すだけになっていたのを、type_cast_type_castで行っていた処理を行うようにして、_type_castを削除するよう修正しています。


Improve language in upgrading guide

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

One file, one constant (at the same top-level)の項の言い回しを修正しています。


Add automatic shard swapping middleware

Active Recordの修正です。

DBのshardのスワッピングを自動で行う為のRack middlewareを追加しています。

複数DB用のmiddlewareと同様に、requestの内容を元にどのsharedを使用するか、というresolverを指定出来るようになっています。

config.active_record.shard_resolver = ->(request) {
  subdomain = request.subdomain
  tenant = Tenant.find_by_subdomain!(subdomain)
  tenant.shard
}

また、request毎のスワッピングを禁止したい場合は、config.active_record.shard_selector{ lock: true }を指定すればよいようになっています。


Introduce ActiveSupport::IsolatedExecutionState for internal use

Active Supportの修正です。

requestやjobのlocal dataの保持にThreadを使うようになっていたのを、Fiberを使用出来るよう修正しています(ThreadだとEnumeratorのように異なるFiberで実行される処理で問題になっていた為)。

Threa / Fiberどちらを使用するかはconfig(config.active_support.isolation_level)で指定出来るようになっており、デフォルトはThreadになっています。Fiberにしたい場合は、左記configに:fiberを指定すればOKです。

rails commit log流し読み(2021/11/17)

2021/11/17分のコミットです。

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


Fix a regression in association preloader

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

Fix STI in available_records causing new instances of records to be loaded from databaseの対応により、preloaderに同じidを持つ違うclassのrecordを指定した場合に、存在しないrecordの読み込みを行おうとしてしまう、というリグレッションが発生してしまっていたのを修正しています。


[ci skip] Rephrase SQL Injection countermeasure - positional & named handlers

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

SQL Injectionの項にあるSQL Injectionの対策について説明している箇所の言い回しを修正しています。


Upgrade jsbundling-rails version to support the source maps. (#43656)

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

rails newで生成するアプリケーションのGemfile内のjsbundling-railsのバージョン指定を">= 0.2.0"に修正しています。source mapをサポートしているのが0.2.0以上の為。


Not needed

railties/CHANGELOG.mdの修正です。

先の対応で不要なCHANGELOGの更新が行われていたのを削除しています。

rails commit log流し読み(2021/11/16)

2021/11/16分のコミットです。

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

actionview/CHANGELOG.md

activesupport/CHANGELOG.md


Enrich the introduction for debug gem (#43621)

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

Debugging with the debug gemの項に、debugging sessionの起動方法や、session内で使えるコマンドについての説明等を追加しています。


docs: true/false typo

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

Merging of scopesの項にあるexampleコードが、実際の結果と異なる値になっていたのを修正しています。


Fix flaky test in HasManyThroughDisableJoinsAssociationsTest

activerecord/test/models/author.rbの修正です。

テストで使用するassociationにorderの指定を追加しています。。orderを指定しないと結果の順番が不定になる為。


Enable Lint/DuplicateMethods rubocop rule

Lint/DuplicateMethods copを追加、及び、各ファイルにcopを適応しています。


Merge pull request #43650 from gmcgibbon/fixes_for_38957

actiontext/app/javascript/actiontext/attachment_upload.jsの修正です。

Action Textで行っているdirect upload処理について、Pass service_name param to DirectUploadsControllerの変更内容に合わせて引数の修正を行っています。


Require MFA to release rails

gemspecの修正です。

MFAの設定がされてないとrubygemsにgemをリリース出来ないよう、gemのmetadataにrubygems_mfa_requiredの指定を追加しています。


Install github cli in dev container

.devcontainer/Dockerfile.devcontainer/library-scripts/github-debian.shの修正です。

dev containerにGitHub CLIをインストールするよう修正しています。


Fix the Dockerfile

.devcontainer/Dockerfileの修正です。

先のコミットで追加したgithub-debian.shのパスが誤っていたのを修正しています。


Fix gemspec

gemspecの修正です。

rubygems_mfa_requiredの値の指定方法が誤っていたのを修正しています。


Merge PR #42755

actionview/lib/action_view/base.rbactionview/lib/action_view/helpers/active_model_helper.rbの修正です。

Base.field_error_procActionView::Baseインスタンスのcontext内で実行するよう修正しています。これにより、下記のように、field_error_procに指定するblockにActionView::Baseに定義されているメソッドが使えるようになっています。

config.action_view.field_error_proc = proc { |html| content_tag(:div, html, class: "field_with_errors") }

Merge PR #43409

Action Viewの修正です。

FormBuilder#field_nameと引数に指定された値からname attributeの値を生成するfield_nameメソッドを追加しています。

form_for @post do |f|
  f.text_field :title, name: f.field_name(:title, :subtitle)
  # => <input type="text" name="post[title][subtitle]">
end
form_for @post do |f|
  f.field_tag :tag, name: f.field_name(:tag, multiple: true)
  # => <input type="text" name="post[tag][]">
end

Support name Symbol to FormBuilder#button

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

FormBuilder#buttonの第一引数にname attributeに使用する為の値をSymbolを指定出来るよう修正しています。

form.button(:draft, value: true)
# => <button name="post[draft]" value="true" type="submit">Create post</button>
form.button(:draft, value: true) do
  content_tag(:strong, "Save as draft")
end
# =>  <button name="post[draft]" value="true" type="submit">
#       <strong>Save as draft</strong>
#     </button>

Support Object#with_options without a block

activesupport/lib/active_support/core_ext/object/with_options.rbactivesupport/lib/active_support/option_merger.rbの修正です。

Object#with_optionsの引数にblockを指定しなかった場合に、ActiveSupport::OptionMergerインスタンスを戻り値とするよう修正しています。decorateしたobjectをベースにview helperを実行出来るようにする為。

module MyStyledHelpers
  def styled
    with_options style: "color: red;"
  end
end

styled.link_to "I'm red", "/"
#=> <a href="/" style="color: red;">I'm red</a>

styled.button_tag "I'm red too!"
#=> <button style="color: red;">I'm red too!</button>

Fix typos in the script

.devcontainer/library-scripts/github-debian.shの修正です。

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


Invert conditional

activesupport/lib/active_support/core_ext/object/with_options.rbの修正です。

with_optionsメソッド内のblock引数がnilかどうかのチェックを反転しています。不要なメソッド呼び出しを避けれるようにする為。


Fix typo in the documentation

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

doc内のグラマーの修正を行っています。


Remove warnings on AS/test/cache/stores

activesupport/test/cache/stores/mem_cache_store_test.rbactivesupport/test/cache/stores/redis_cache_store_test.rbの修正です。

テスト実行時にRubyのwarning(instance variable xxx not initialized)が出ていたのを修正しています。


Merge PR #43413

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

button_toメソッドで生成するformで、引数のmodelの状態に合わせて使用するHTTP verbを変更する(保存済みのレコードの場合patchを使用する)よう修正しています。

button_to(Workshop.find(1)){ "Update" }
#=> <form method="post" action="/workshops/1" class="button_to">
#=>   <input type="hidden" name="_method" value="patch" autocomplete="off" />
#=>   <button type="submit">Update</button>
#=> </form>

button_to([ Workshop.find(1), Session.find(1) ]) { "Update" }
#=> <form method="post" action="/workshops/1/sessions/1" class="button_to">
#=>   <input type="hidden" name="_method" value="patch" autocomplete="off" />
#=>   <button type="submit">Update</button>
#=> </form>

Merge PR #43416

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

fieldsメソッドのmodel引数にnestしたmodel(e.g. [@nested, @model])を指定出来るよう修正しています。form_withmodel引数と挙動を合わせる為。


Remove code duplication by extracting the _object_for_form_builder private method

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

値がArrayだった場合に値のlastを取得する、という処理が複数箇所にあったのでメソッドに切り出しています。


Fix typo in the documentation

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

コンポーネント名について説明している箇所のActiveModelActive Modelに修正しています。


Link to listing existing routes

rails guideのRails Routing from the Outside Inの修正です。

Path and URL Helpersの項に、route helperを検索する方法について説明しているListing Existing Routesへのリンクを追加しています。