なるようになるブログ

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

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

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

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

actiontext/CHANGELOG.md

activerecord/CHANGELOG.md

actionpack/CHANGELOG.md


This should not be in the codeblock

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

ActiveSupport::Notificationsのdocのフォーマットを修正しています。


ActionText: Strip content attribute if it's empty during render_attachments

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

Action Textのcontentを編集後再度アクセスした場合に、リッチテキスト領域に追加された画像やその他の添付ファイルがエディターに表示されないバグがあったのを修正しています。


Merge pull request #44841 from sdrew/ar-point-hash

activerecord/lib/active_record/connection_adapters/postgresql/oid/point.rbの修正です。

Hashを使用した値に対する、ActiveRecord::Point 型キャストのサポートを追加しています。これにより、ActiveRecord::Pointを数値の:x:y のキーを持つハッシュから、キャストまたはシリアル化できるようになっています。

class PostgresqlPoint < ActiveRecord::Base
  attribute :x, :point
  attribute :y, :point
  attribute :z, :point
end

val = PostgresqlPoint.new({
  x: '(12.34, -43.21)',
  y: [12.34, '-43.21']
})

ActiveRecord::Point.new(12.32, -43.21) == val.x # => true
ActiveRecord::Point.new(12.32, -43.21) == val.y # => true

Fix center alignment issue in guides blocks

rails guideの修正です。

guide内のヒントとメモブロックの中央揃えの位置がずれていたのを修正しています。


Infer default :inverse_of option for delegated_type

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

delegated_typeでmodel名から自動でinverse_ofの指定を行うよう修正しています。

class Entry < ApplicationRecord
  delegated_type :entryable, types: %w[ Message ]
  # => `inverse_of: :entry`
end

合わせて、独自のassociation名を使用している場合のために、delegated_typeinverse_ofオプションを指定出来るよう対応しています。


Fix raw_post raising when rack.input is nil

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

rack.inputnilの場合に、Request#raw_postメソッドがNoMethodErrorをraiseするバグがあったのを修正しています。元々rack.inputnilになることはなかったのですが、Rack 3.1からoptionalになりnilになることがあるため。


Fix Action Mailbox assuming request.body present

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

rack.inputnilの場合に、inbound emailの作成処理でNoMethodErrorをraiseするバグがあったのを修正しています。元々rack.inputnilになることはなかったのですが、Rack 3.1からoptionalになりnilになることがあるため。


Merge pull request #52597 from flavio-b/patch-1

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

RESTful Downloadsセクション内の独自のmime typeを登録する方法について説明している箇所に、Railsにデフォルトで登録されているmimeの確認方法や、追加する際のメソッドの詳細についての説明を追加しています。


Improve Action Text System Test coverage

actiontext/test/system/rich_text_editor_test.rbactiontext/test/system/system_test_helper_test.rbの修正です。

Action TextのActive Storageとのintegrationに関する挙動を確認するためのテストを追加しています。


Fix linting issues in action_controller_overview.md

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

lintでエラーになる箇所があったのを修正しています。


Merge pull request #52637 from jlduran/cleanup-service-worker-white-space

railties/lib/rails/generators/rails/app/templates/app/views/pwa/service-worker.jsの修正です。

行末尾の不要な空白を削除しています。


Add store_if_blank option to has_rich_text

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

has_rich_textメソッドに、値が空の場合に保存するかどうかを指定するためのstore_if_blankオプションを追加しています。store_if_blankがfalse、かつ、値が空の場合、保存は行われないようになります。

class Message
  has_rich_text :content, store_if_blank: false
end

Message.create(content: "hi") # ActionText::RichText が作成される
Message.create(content: "")   # ActionText::RichText が作成されない

Merge pull request #52490 from Uaitt/improve-credentials-help-output

railties/lib/rails/commands/credentials/USAGEの修正です。

bin/rails credentials:helpで表示されるテキストのフォーマットや言い回しを修正しています。


Merge pull request #52357 from Uaitt/clarify-upgrading-ruby-on-rails-guide

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

The Upgrade Processセクション内のRailsを更新する手順を説明している箇所で、bundle updateコマンドにgem名(rails)を指定するよう修正しています。


Merge pull request #52546 from Uaitt/config-assets-quiet-improvements

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

config.assets.quietについて説明している箇所内のdevelopment.rbconfig/environments/development.rbに修正しています。


Encryption casting with encrypts before serialize (#52650)

Active Recordの修正です。

Active Record EncryptionでDBの値を復号化する前にdeserialize処理を行うよう修正しています。PostgreSQLのbinary value(ActiveRecord::ConnectionAdapters::PostgreSQL::OID::Bytea)をencryptに使用した場合に、deserializeが先に行われないと値の復号が正しく行えない為。