2024/07/30分のコミットです。
CHANGELOGにのったコミットは以下の通りです。
activemodel/CHANGELOG.md
- Add a load hook
active_model_translationforActiveModel::Translation. - Add
raise_on_missing_translationsoption toActiveModel::Translation.
activestorage/CHANGELOG.md
Authentication generator supports an --api flag (#52442)
railtiesの修正です。
authentication generatorで--api modeをサポートするよう修正しています。
railties/lib/rails/generators/rails/authentication/templates/controllers/sessions_controller.rbの修正です。
newメソッドのexampleコードから明示的な再ログインのための処理を削除しています。ここでわざわざ明示的に記載する必要はないだろう、とのことです。
activemodel/lib/active_model/type/helpers/time_value.rb、
activemodel/lib/active_model/type/helpers/timezone.rbの修正です。
fast_string_to_timeメソッドについて、Ruby 3.2.0にあるバグのためのコードをメソッド定義時に必要かどうかをチェックし、不要なバージョンではバグのためのコードを含まないよう修正、及び、最新のRubyだと不要な文字列のフォーマットのチェック処理を行わないよう修正しています。
Add bin/dev by default (#52433)
railties/lib/rails/generators/rails/app/templates/bin/dev.ttの修正です。
新規にアプリケーションを作成した場合に、bin/devファイルを生成するよう修正しています。中身はbin/rails serverを実行しているだけです。jsbundling やimportmapsでbin/devを使用するようになっており、同じようにdev modeを起動出来るようにするため。
docs: use as_json per method instead of to_json
activesupport/lib/active_support/time_with_zone.rbのdocの修正です。
as_jsonメソッドのdoc内のexampleコードでto_jsonを使用していたのを、as_jsonを使用するよう修正しています。
Merge pull request #52384 from fatkodima/custom-batch-columns
Active Recordの修正です。
batch系のAPIで、cursor columnを指定出来るよう修正しています。
Product.in_batches(cursor: [:shop_id, :id]) do |relation| # do something with relation end
Change ActiveModel human_attribute_name to raise an error
activemodel/lib/active_model/translation.rb、
activesupport/lib/active_support/i18n_railtie.rbの修正です。
ActiveModel::Translationにraise_on_missing_translationsオプションを追加しています。このオプションがtrueの場合、指定されたattributeのtranslationが存在しない場合にhuman_attribute_nameがexceptionをraiseするようになっています。
Post.human_attribute_name("title") # => Translation missing. Options considered were: (I18n::MissingTranslationData)
なお、config.i18n.raise_on_missing_translationsがraise_on_missing_translationsに設定されるようなっているため、config.i18n.raise_on_missing_translationsがtrueの場合はraise_on_missing_translationsもtrueになるようになっています。
合わせて、ActiveModel::Translationがloadされたときに実行されるactive_model_translation hookを追加しています。
Merge pull request #50838 from fractaledmind/ar-fix-sqlite-table-structure-parsing
activerecord/lib/active_record/connection_adapters/sqlite3_adapter.rbの修正です。
SQLite3 adapterで、columnの定義にfunctionを使用している、かつ、functionにカンマが含まれているような場合(e.g. t.virtual :mutated_name, type: :string, as: "REPLACE(name, 'l', 'L')")に、テーブル定義にそのfunctionが正しく反映されないバグがあったのを修正しています。
Improve InvariableError, UnpreviewableError and UnrepresentableError message
activestorage/app/models/active_storage/blob/representable.rbの修正です。
ActiveStorage::InvariableError、ActiveStorage::UnpreviewableError、及び、ActiveStorage::UnrepresentableErrorのエラメッセージにBlob IDとcontent_typeを含むよう修正しています。