# Creating multiple records in one form

**URL:** <https://www.ruby-forum.com/t/creating-multiple-records-in-one-form/128899>\
**Category:** Rails\
**Created:** [February 12, 2008, 3:18pm UTC](https://www.ruby-forum.com/t/creating-multiple-records-in-one-form/128899 "2008-02-12T15:18:44Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![casper\_the\_ghost](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/58956e/32.png) [@casper\_the\_ghost](https://www.ruby-forum.com/u/casper_the_ghost)\
**Post date:** [February 12, 2008, 3:18pm UTC](https://www.ruby-forum.com/t/creating-multiple-records-in-one-form/128899/1 "2008-02-12T15:18:44Z")

</div>

I want to have a form with which the user can choose options (meal  
choices) for themselves and a number of ‘dinner companions’. The  
number is pre-specified in a different form. I have an attendee model,  
and a ‘diner’ model which has an attendee\_id field, and a  
‘diner\_number’ field - so if the attendee wants to have 2 companions  
the diner id’s would be 0 for the attendee themselves, and 1, 2 for  
the companions. I wanted to do this so that there was no way to  
submit choices for anyone elses dinner.

The problem is, I’m not sure how to get this working properly - I have  
it set up to make a number of entry options in the form, each with the  
index set to 0, 1, 2…, but it’s how to a) make these work with  
newly created objects, so that they have the correct defaults upon  
form creation, and secondly how to process this data in the controller  
upon submission - and have validation working properly.

Does this make sense, and any thoughts?
