You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Application upgraded from 4.2 to 5.0.0 following the official upgrade guides.
Unusual behaviour in fields_for when used to batch create or update records using model[].
(Guidelines for creating a bug report are available
here)
Expected behavior
Something like the following should create an input to update an attribute of an association that belongs_to a record, customisable:
= form_for(controller: 'records', action: 'batch_create') do
- @records.each do |record|
= fields_for('associations[]', record.association) do |assoc|
= assoc.number_field(:association_attribute)
Expected HTML:
<formfoo="bar"><inputtype="number" name="associations[1][association_attribute]" />
<inputtype="number" name="associations[2][association_attribute]" />
<!-- repeat for each associated record --></form>
Actual behavior
HTML produced:
<formfoo="bar"><inputtype="number" name="associations[association_attribute]" />
<inputtype="number" name="associations[association_attribute]" />
<!-- repeat for each associated record --></form>
This produces the same behaviour as if we had just used fields_for('associations')
System configuration
Rails version: 5.0.0
Ruby version: 2.2.3
The text was updated successfully, but these errors were encountered:
Can you create an executable test script using one of the templates here, that would demonstrate the problem you are seeing? Also, since you're saying this worked for you in Rails 4.2.x, can you do a git bisect to determine where a possible regression may have been introduced?
On a very quick look, looks like this could be related to #26931.
When you ask to generate multiple nested inputs using:
field_for('comments[]', Comment.new) do |c|
c.text_field :body
Rails should generated the names like `post[comments][][body]`.
To make sure we don't have regression the fake models now use the same
implementation of `#to_param` as `ActiveRecord::Base`
Fixes#26942
Steps to reproduce
Application upgraded from 4.2 to 5.0.0 following the official upgrade guides.
Unusual behaviour in
fields_for
when used to batch create or update records usingmodel[]
.(Guidelines for creating a bug report are available
here)
Expected behavior
Something like the following should create an input to update an attribute of an association that
belongs_to
a record, customisable:Expected HTML:
Actual behavior
HTML produced:
This produces the same behaviour as if we had just used
fields_for('associations')
System configuration
Rails version: 5.0.0
Ruby version: 2.2.3
The text was updated successfully, but these errors were encountered: