1
0
Fork 0
mirror of https://github.com/rails/rails.git synced 2022-11-09 12:12:34 -05:00
This commit is contained in:
Rafael Mendonça França 2021-11-15 22:55:37 +00:00 committed by GitHub
commit 846f9e9595
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 16 additions and 0 deletions

View file

@ -1,3 +1,8 @@
* Support `fields model: [@nested, @model]` the same way as `form_with model:
[@nested, @model]`.
*Sean Doyle*
* Infer HTTP verb `[method]` from a model or Array with model as the first
argument to `button_to` when combined with a block:

View file

@ -1078,6 +1078,7 @@ module ActionView
options[:skip_default_ids] = !form_with_generates_ids
if model
model = model.last if model.is_a?(Array)
scope ||= model_name_from_record_or_class(model).param_key
end

View file

@ -2065,6 +2065,16 @@ class FormWithActsLikeFormForTest < FormWithTest
assert_dom_equal expected, output_buffer
end
def test_fields_with_only_object_array
output_buffer = fields(model: [@post, @comment]) do |f|
concat f.text_field(:name)
end
expected = %(<input type="text" value="new comment" name="comment[name]" id="comment_name" />)
assert_dom_equal expected, output_buffer
end
def test_fields_object_with_bracketed_name
output_buffer = fields("author[post]", model: @post) do |f|
concat f.label(:title)