Forum: Ruby on Rails Nested Model Form

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
Nash (Guest)
on 2009-03-24 18:14
(Received via mailing list)
I noticed when I have a form up that reflects a parent and two types
of children that the names of the field use a global index of the
total number of available children. I expected it to be scoped per
child type.

For example, if I have post that has_many comments_type1 and many
comments_type2, the form would look something like this

<input type="text" name="post[comments_type1_attributes][0]" />
<input type="text" name="post[comments_type2_attributes][1]" />

Shouldn't the second input's name be post[comments_type2_attributes]
[0] ?

The code that does this is in actionpack-2.3.2/lib/action_view/helpers/
form_helper.rb on line 1028.

Thanks.


-Nash
This topic is locked and can not be replied to.