Forum: Ruby on Rails Creating multiple child objects in a form

Announcement (2017-05-07): is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see and for other Rails- und Ruby-related community platforms.
6661ef9d747db3af8896cd94959d717d?d=identicon&s=25 Paul Barry (Guest)
on 2006-05-24 22:30
(Received via mailing list)

I have a Response object and it has many answers.  I would like to
create a
form that allows me to create a new Response object that has 5 Answer
objects.  Can I do this using the form_for FormBuilder?  I assume what I
want to generate is something like this:

<input type="text" name="response[answer][0][answer_value]"/>
<input type="text" name="response[answer][1][answer_value]"/>
<input type="text" name="response[answer][2][answer_value]"/>
<input type="text" name="response[answer][3][answer_value]"/>
<input type="text" name="response[answer][4][answer_value]"/>

And then I'm hoping that when it gets submitted to the controller, I can
response =[:response]) and response.answer will
5 answer objects with each of their answer_value properties populated.
This topic is locked and can not be replied to.