Join GitHub today
GitHub is home to over 28 million developers working together to host and review code, manage projects, and build software together.Sign up
Handle nested fields_for by adding indexes to record_name #21431
Thanks for the pull request, and welcome! The Rails team is excited to review your changes, and you should hear from @sgrif (or someone else) soon.
If any changes to this PR are deemed necessary, please add them as extra commits. This ensures that the reviewer can see what has changed since they last reviewed the code. Due to the way GitHub handles out-of-date commits, this should also make it reasonably obvious what issues have or haven't been addressed. Large or tricky changes may require several passes of review and changes.
Please see the contribution instructions for more information.
Yeah, it should be the same as https://github.com/ojab/rails/blob/master/actionview/test/template/form_helper_test.rb#L2326
Also I've run a benchmark for the
form_for(:posts) do |f| f.fields_for('post', @post) do |f2| f2.text_field(:id) end end
but results are inconclusive, I'm getting very close results with large stddev:
orig -- rails without patch, gsub -- rails with this PR applied, substr -- record_name is formed using
added a commit
this pull request
Sep 26, 2015
I've come across a situation that is effected by this change and wanted to check that this is correct
I can get around this by passing an empty index
I'm not quite sure what exactly you want to archive. My testcase (using rails-4.2.6) produces input field w/
and I doubt that it is what you want.
And params looks like:
It works perfect in Rails 4.2.5, but fails in Rails 5.
Again I don't know if this behavior of fields_for was a bug or a feature, but it looks like there is no way to get params as array using fields_for now.