# Add/edit child models in one form

**URL:** <https://www.ruby-forum.com/t/add-edit-child-models-in-one-form/114571>\
**Category:** Rails\
**Created:** [September 15, 2007, 8:18pm UTC](https://www.ruby-forum.com/t/add-edit-child-models-in-one-form/114571 "2007-09-15T20:18:56Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![roa](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/8e7dd6/32.png) [@roa](https://www.ruby-forum.com/u/roa)\
**Post date:** [September 15, 2007, 8:18pm UTC](https://www.ruby-forum.com/t/add-edit-child-models-in-one-form/114571/1 "2007-09-15T20:18:56Z")

</div>

Hi all

I’m a ruby beginner so I hope to get some help on this forum. I have  
seen that there are allready some posts on this subject, but I can’t  
seem to get them to work on my test project.

To give some info. I have a table Contacts. This table contains some  
information on a person like name, address, etc. The table notas  
contains a simple id, an contact\_id and a field for the nota itself.

In my Nota model I say the following thing: belongs\_to : contact  
In my Contact model I say: has\_many :notas

I have generated my new/edit contact form through the ruby script  
scaffold. Offcours it only contains all the contact fields. So I added  
the following:  
…

…

if(@contact.notas)  
@contact.notas.each do |nota| %\>  
  
\<%= nota.nota %\>  
  
  
\<% end end %\>

  
....

For test reasons I allready added some notas in the DB with phpMyAdmin.  
And so far, so good, alle the notas for a certain contact are displayed.

But when I add or edit them through the application, I get the following  
error:  
undefined method `nota=’ for #Contact:0x474d69c

This is probably due to the fact that the contact model doesn’t has any  
fields called nota. So I should tell RoR to add/edit those fields in the  
notas table (most likely in the update methode of the Contact  
controller). But as I said, I’m only a ruby beginner, and I would realy  
like to know how you can accomplish this in ruby on rails.

The reason for this is that I have a similar tool (its bigger and has  
more functionality to it) written in PHP, but after reading up on ruby  
on rails I believe that ruby is the way to the futur. I have allready  
searched through some books on ruby (on rails) that I bought, but I  
can’t seem to find a familiar case study on it.

So hopefully there is someone who can point me to the right direction.

Thank you in advance
