2021/11/16分のコミットです。
CHANGELOGにのったコミットは以下の通りです。
- Execute the
ActionView::Base.field_error_proc
within the context of theActionView::Base
instance: - Introduce the
field_name
view helper, along with theFormBuilder#field_name
counterpart: - Support passing a Symbol as the first argument to
FormBuilder#button
- Infer HTTP verb
[method]
from a model or Array with model as the first argument tobutton_to
when combined with a block: - Support
fields model: [@nested, @model]
the same way asform_with model: [@nested, @model]
Enrich the introduction for debug gem (#43621)
rails guideのDebugging Rails Applications
の修正です。
Debugging with the debug gem
の項に、debugging sessionの起動方法や、session内で使えるコマンドについての説明等を追加しています。
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の変更内容に合わせて引数の修正を行っています。
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をインストールするよう修正しています。
.devcontainer/Dockerfile
の修正です。
先のコミットで追加したgithub-debian.sh
のパスが誤っていたのを修正しています。
gemspecの修正です。
rubygems_mfa_required
の値の指定方法が誤っていたのを修正しています。
actionview/lib/action_view/base.rb
、
actionview/lib/action_view/helpers/active_model_helper.rb
の修正です。
Base.field_error_proc
をActionView::Base
のインスタンスのcontext内で実行するよう修正しています。これにより、下記のように、field_error_proc
に指定するblockにActionView::Base
に定義されているメソッドが使えるようになっています。
config.action_view.field_error_proc = proc { |html| content_tag(:div, html, class: "field_with_errors") }
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.rb
、
activesupport/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>
.devcontainer/library-scripts/github-debian.sh
の修正です。
location
をlocaiton
にタイポしていたのを修正しています。
activesupport/lib/active_support/core_ext/object/with_options.rb
の修正です。
with_options
メソッド内のblock引数がnilかどうかのチェックを反転しています。不要なメソッド呼び出しを避けれるようにする為。
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.rb
、
activesupport/test/cache/stores/redis_cache_store_test.rb
の修正です。
テスト実行時にRubyのwarning(instance variable xxx not initialized
)が出ていたのを修正しています。
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>
actionview/lib/action_view/helpers/form_helper.rb
の修正です。
fields
メソッドのmodel
引数にnestしたmodel(e.g. [@nested, @model]
)を指定出来るよう修正しています。form_with
のmodel
引数と挙動を合わせる為。
Remove code duplication by extracting the _object_for_form_builder private method
actionview/lib/action_view/helpers/form_helper.rb
の修正です。
値がArrayだった場合に値のlast
を取得する、という処理が複数箇所にあったのでメソッドに切り出しています。
actionview/lib/action_view/model_naming.rb
のdocの修正です。
コンポーネント名について説明している箇所のActiveModel
をActive Model
に修正しています。
Link to listing existing routes
rails guideのRails Routing from the Outside In
の修正です。
Path and URL Helpers
の項に、route helperを検索する方法について説明しているListing Existing Routes
へのリンクを追加しています。