なるようになるブログ

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

rails commit log流し読み(2023/05/31)

2023/05/31分のコミットです。

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

actionview/CHANGELOG.md

actioncable/CHANGELOG.md

actionpack/CHANGELOG.md


Merge pull request #48293 from flavorjones/flavorjones-support-html5-sanitizer

Action Viewの修正です。

rails-html-sanitizer 1.6.0で追加されたHTML5の標準に準拠したsanitizerをAction Viewで使用出来るよう修正しています。デフォルトは古いsanitizer(Rails::HTML4::Sanitizer)を使用するようになっており、config.action_view.sanitizer_vendorRails::HTML::Sanitizer.best_supported_vendorを指定した場合、かつ、使用出来る場合は新しく追加されたsanitizer(Rails::HTML5::Sanitizer)が使用されるようになっています。


Merge pull request #48323 from Eric-Guo/ci_fixture_vendor_no_loading

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

自動でtest/fixturesRails engineのfixture_pathsに設定する際に、vendor配下のtest/fixturesは設定しないよう修正しています。


Merge pull request #48199 from JoeDupuis/remove-url-rewriter-tests

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

大分昔に削除されたUrlRewriterという機能に対するテストが残っていたのを削除しています。


Merge pull request #48222 from JoeDupuis/health-check-standalone-cable

Action Cableの修正です。

health check用のpath、及び、Rackアプリケーションをconfig(health_check_pathhealth_check_application)で指定出来るよう修正しています。Action Cableのserverをstandaloneで使用するような場合に、health checkの設定を出来るようにする為。


Preserve timestamp when setting an ActiveSupport::TimeWithZone value to timestamptz attribute

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

ActiveRecord::Base.time_zone_aware_types:timestamptzを追加しているのに、timestamptzを使用しているattributeでtimezoneが保持されないバグがあったのを修正しています。


Fix humanize for strings ending with id

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

末尾がidになっているStringに対してhumanizeを実行した場合に、id部分が削除されてしまうバグがあったのを修正しています。


Merge pull request #43770 from terracatta/add_bind_params_to_url_helper

Action Packの修正です。

url helperのoptionに、query parameterを指定する為のpath_paramsオプションを追加しています。 例えば、下記のようにroutes、及び、controllerでpath_paramsオプションを指定した場合、

Rails.application.routes.draw do
  scope ":account_id" do
    get "dashboard" => "pages#dashboard", as: :dashboard
    get "search/:term" => "search#search", as: :search
  end
  delete "signout" => "sessions#destroy", as: :signout
end
class ApplicationController < ActionController::Base
  def default_url_options
    { path_params: { account_id: "foo" } }
  end
end

scopeで定義したaccount_idのデフォルトとしてcontrollerで定義した値が使用されるようになり、下記のようなpathが生成されるようになっています。

dashboard_path # => /foo/dashboard
dashboard_path(account_id: "bar") # => /bar/dashboard
search_path("quin") # => /foo/search/quin

signout_path # => /signout
signout_path(account_id: "bar") # => /signout?account_id=bar
signout_path(account_id: "bar", path_params: { account_id: "baz" }) # => /signout?account_id=bar