# how to create a form for multiple entries?

**URL:** <https://discuss.rubyonrails.org/t/how-to-create-a-form-for-multiple-entries/50685>\
**Category:** rubyonrails-talk\
**Created:** [April 6, 2010, 6:01am UTC](https://discuss.rubyonrails.org/t/how-to-create-a-form-for-multiple-entries/50685 "2010-04-06T06:01:37Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Gordon\_Yeong](https://avatars.discourse-cdn.com/v4/letter/g/e47c2d/32.png) [@Gordon\_Yeong](https://discuss.rubyonrails.org/u/Gordon_Yeong)\
**Post date:** [April 6, 2010, 6:01am UTC](https://discuss.rubyonrails.org/t/how-to-create-a-form-for-multiple-entries/50685/1 "2010-04-06T06:01:37Z")

</div>

hi guys,

&nbsp;&nbsp;I have a fairly simple application for a party.

An "invite" object has many "guest" objects.

When I open up localhost:3000/invites/:id/guests/, I expect to see the details of the "invite" along with all the guest objects associated with the given invite.

I would like to have a form whereby there's a checkbox on the left of each guest entry which represents if the guest has decided to attend the party (or not).

Nevertheless, I kept getting this error, " undefined method `guest\_path' for #\<ActionView::Base:0x0000001138fe88\>" when i open the url above.

I am not sure what I am doing wrong. Anyway, this is how my "~/ projects/party/app/views/guests/index.rhtml" looks like. Yes, I am aware this is not following CRUD closely but it's a very simple app hence I have stripped a lot of things down.

---------- extract start -------------------------------

\<h1\>Listing guests\</h1\>

\<% @guests.each do |guest| %\> &nbsp;&nbsp;&nbsp;&nbsp;\<% form\_for(guest) do |f| %\> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;\<%= f.error\_messages %\>

&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;\<p\> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;\<%= f.label :name %\>\<br /\> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;\<%= f.text\_field :name %\> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;\</p\> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;\<p\> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;\<%= f.label :contact\_number %\>\<br /\> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;\<%= f.text\_field :contact\_number %\> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;\</p\> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;\<p\> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;\<%= f.label :status %\>\<br /\> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;\<%= f.check\_box :status %\> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;\</p\> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;\<p\> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;\<%= f.label :email %\>\<br /\> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;\<%= f.text\_field :email %\> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;\</p\> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;\<p\> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;\<%= f.submit 'Update' %\> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;\</p\> &nbsp;&nbsp;&nbsp;&nbsp;\<% end %\> \<% end %\>

---------- extract end -------------------------------

Any ideas on how to create the multielement form, guys?

thanks

---

<div class="post-metadata">

**Author:** ![Christophe1](https://avatars.discourse-cdn.com/v4/letter/c/b3f665/32.png) [@Christophe1](https://discuss.rubyonrails.org/u/Christophe1)\
**Post date:** [April 6, 2010, 7:29am UTC](https://discuss.rubyonrails.org/t/how-to-create-a-form-for-multiple-entries/50685/2 "2010-04-06T07:29:34Z")

</div>

I'm not a professional Rails developper but I believe I went through the same kind of issue. So take a look at this: [#75 Complex Forms Part 3 - RailsCasts](http://railscasts.com/episodes/75-complex-forms-part-1) and possibly part-2 and 3 as well.

Christophe

---

<div class="post-metadata">

**Author:** ![Nicolas\_Iensen](https://avatars.discourse-cdn.com/v4/letter/n/8e7dd6/32.png) [@Nicolas\_Iensen](https://discuss.rubyonrails.org/u/Nicolas_Iensen)\
**Post date:** [April 6, 2010, 11:39am UTC](https://discuss.rubyonrails.org/t/how-to-create-a-form-for-multiple-entries/50685/3 "2010-04-06T11:39:01Z")

</div>

It seems that you created the guest and invite routes nested, right?

So, you have to write your form like this:

\<% form\_for([@invite, guest]) do |f| %\>

This form above will use the url: /invites/:invite\_id/guests/:id/edit

Some reference: [http://adamblog.heroku.com/past/2007/12/20/nested\_resources\_in\_rails\_2/](http://adamblog.heroku.com/past/2007/12/20/nested_resources_in_rails_2/)

Cheers!

Nícolas Iensen
