Tech Racho エンジニアの「?」を「!」に。
  • Ruby / Rails関連

Rails 8.1.0.beta1のChangelog: Action View(全項目リンク付き)

🔗 Action View CHANGELOG

参考: Release 8.1.0.beta1 · rails/rails
参考: コミットリスト: Comparing v8.0.2.1...v8.1.0.beta1 · rails/rails

🔗 Allow current_page? to match against specific HTTP method(s) with a method: option by bensheldon · Pull Request #55286 · rails/rails

current_page?ヘルパーでmethod:オプションが追加された。これによりHTTPメソッドをmethod: [:post, :put, :delete]のように指定可能になった。

Ben Sheldon
同Changelogより

🔗 [Fix #55209] Remove autocomplete="off" from hidden inputs in button_to by nkulway · Pull Request #55336 · rails/rails

button_toフォームに含まれるhiddenパラメータフィールドがautocomplete="off"を含まないようになった。これは、UrlHelperのhidden入力からautocomplete="off"属性を削除する目的で行われた。また、form_tag(非推奨)やtoken_tag(Rails 4で廃止)やmethod_tag(privateメソッド)で生成されるhidden入力もautocomplete="off"を含まなくなる。

nkulway
同Changelogより

#55336については、config.action_view.remove_hidden_field_autocompleteコンフィグが追加され、上述の挙動をオンオフできます。

Starting with version The default value is
(original) false
8.1 true

Rails 5.1〜8.0: 'form_with' APIドキュメント(翻訳)

🔗 Enable configuring Action View's render tracker by skipkayhil · Pull Request #55194 · rails/rails

Action Viewテンプレート間の依存関係をトラッキングする戦略をコンフィグ可能になった。

従来の:regex戦略はデフォルトとして保持されるが、load_defaults 8.1では:ruby(本物のRubyパーサーを使う)戦略が使われるようになる。

Hartley McGuire
同Changelogより

🔗 Add relative_time_in_words helper to ActionView by MatheusRich · Pull Request #55405 · rails/rails

相対時間を英文で返すrelative_time_in_wordsヘルパーを追加。

relative_time_in_words(3.minutes.from_now) # => "in 3 minutes"
relative_time_in_words(3.minutes.ago) # => "3 minutes ago"
relative_time_in_words(10.seconds.ago, include_seconds: true) # => "less than 10 seconds ago"

Matheus Richard
同Changelogより

🔗 Make nonce: false remove the nonce attribute for javascript_tag, javascript_include_tag and stylesheet_link_tag by francktrouillez · Pull Request #54724 · rails/rails

nonce: falseを指定したときに、以下の出力からnonce属性そのものを削除するようになった(従来はnonce="false"が追加されていた)。

francktrouillez
同Changelogより

🔗 Add dom_target helper to create dom_id-like strings from an unlimited number of objects by bensheldon · Pull Request #55204 · rails/rails

dom_targetヘルパーを追加。これはdom_idのような文字列をオブジェクトから生成するが、オブジェクト数に上限はない。

Ben Sheldon
同Changelogより

🔗 Use the given form in html_options for the hidden field in collection_check_boxes by 3v0k4 · Pull Request #51746 · rails/rails

Rails 8.0.2でリリース済み

collection_checkboxesヘルパーで生成したhiddenの<input>タグをhtml_options[:form]に渡しても無視されていた(#51606)のを修正。

Riccardo Odone
同Changelogより

🔗 (https://github.com/rails/rails/pull/54020

Rails 8.0.2でリリース済み

コントローラでrenderに渡したlocalsにレイアウトからアクセスできなくなっていたのを修正。

修正された#31680はRails 5.1のリグレッションバグ。

Mike Dalessio
同Changelogより

🔗 fix: ArgumentErrors raised during template rendering by flavorjones · Pull Request #54133 · rails/rails

Rails 8.0.2でリリース済み

テンプレート内の引数エラーのうち、strict(厳密な)localsに関連するものはActionView::StrictLocalsErrorをraiseし、その他の引数エラーはそのまま再度raiseされるようになった。

従来は、テンプレートのレンダリング中にraiseしたArgumentErrorはstrict localsエラーの処理中に飲み込まれてしまっていたため、strict localsに関連しないArgumentError(誤った引数で呼び出されたヘルパーメソッドなど)が無関係なバックトレースを持つ同様のArgumentErrorに置き換えられてしまい、テンプレートのデバッグが困難になっていた。

修正後は、strict localsに関連しないArgumentErrorが再度raiseされるようになり、開発者向けに元のバックトレースが保持されるようになった。

また、ActionView::StrictLocalsErrorArgumentErrorのサブクラスであるため、ArgumentErrorをrescueする既存のコードは引き続き機能する。

修正: #52227

Mike Dalessio
同Changelogより

🔗 Improve error highlighting of multiline methods in ERB templates by martinemde · Pull Request #53763 · rails/rails

ERBテンプレート内の複数行メソッドや、エラーがテンプレートdo-endブロック内で発生した場合のエラーハイライトが不適切だったのを修正。

Martin Emde
同Changelogより

🔗 fix: ArgumentErrors raised during template rendering by flavorjones · Pull Request #54133 · rails/rails

ERBテンプレートで発生したエラーが、コンパイル済みテンプレートのソーステンプレートの末尾より下の行で発生すると、ERBテンプレートのエラーハイライトがクラッシュする問題を修正。

Martin Emde
同Changelogより

🔗 Redesign ActionView::Template::Handlers::ERB.find_offset to handle edge cases by martinemde · Pull Request #53657 · rails/rails

ERBテンプレートでのエラーハイライトの信頼性を改善した。
エラーハイライト表示での無限ループやクラッシュを修正し、Rails以外のERBハンドラでの動作を改良した。

Martin Emde
同Changelogより

🔗 Allow hidden_field(_tag) to accept a custom autocomplete value by brendon · Pull Request #53512 · rails/rails

hidden_fieldhidden_field_tagにカスタムのオートコンプリート値を渡せるようになった。

brendon
同Changelogより

補足: 従来はFirefoxのバグ対応のため、hiddenフィールドにautocomplete="off"が強制的に追加されていました(#43280)が、これはパスワードマネージャがusernameなどをhiddenフィールドに設定するうえで不都合があるため、他のautocomplete値が設定されていない場合にのみautocomplete="off"をhiddenフィールドに追加するよう修正されました。

🔗 Add a config for automatically including nonce in javascript_tag, javascript_include_tag and stylesheet_link_tag by francktrouillez · Pull Request #53835 · rails/rails

content_security_policy_nonce_autoコンフィグを新たに追加。
これは、既存のcontent_security_policy_nonce_directivesコンフィグで指定されたディレクティブに影響されるタグに自動的にnonceを追加する。

francktrouillez

同Changelogより

関連記事

速報: Rails World 2025のDHHキーノートとRails 8.1beta1リリース

Rails 8.1.0.beta1のChangelog: Active Record(全項目リンク付き)

Rails 8.1.0.beta1のChangelog: Active Support(全項目リンク付き)


CONTACT

TechRachoでは、パートナーシップをご検討いただける方からの
ご連絡をお待ちしております。ぜひお気軽にご意見・ご相談ください。