# Creating more than 1 child for an already existing parent

**URL:** <https://www.ruby-forum.com/t/creating-more-than-1-child-for-an-already-existing-parent/174671>\
**Category:** Rails\
**Created:** [August 31, 2009, 10:21am UTC](https://www.ruby-forum.com/t/creating-more-than-1-child-for-an-already-existing-parent/174671 "2009-08-31T10:21:29Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![akramwasim1234](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/b3f665/32.png) [@akramwasim1234](https://www.ruby-forum.com/u/akramwasim1234)\
**Post date:** [August 31, 2009, 10:21am UTC](https://www.ruby-forum.com/t/creating-more-than-1-child-for-an-already-existing-parent/174671/1 "2009-08-31T10:21:29Z")

</div>

hi all,

```
     i have a parent by namr "consultancy"

```

I want to create more than 1 child models for analready existing  
consultancy which has some extra feilds

Plz help me in this regard.

---

<div class="post-metadata">

**Author:** ![akramwasim1234](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/b3f665/32.png) [@akramwasim1234](https://www.ruby-forum.com/u/akramwasim1234)\
**Post date:** [August 31, 2009, 10:58am UTC](https://www.ruby-forum.com/t/creating-more-than-1-child-for-an-already-existing-parent/174671/2 "2009-08-31T10:58:23Z")

</div>

2009/8/31 Kart [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid):

> hi all,
> 
> Â Â Â Â i have a parent by namr “consultancy”
> 
> I want to create more than 1 child models for analready existing  
> consultancy which has some extra feilds

Do you mean that you have  
Consultancy has\_many :children

and you now want to change the Child model so that it has extra fields?

Colin

---

<div class="post-metadata">

**Author:** ![akramwasim1234](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/b3f665/32.png) [@akramwasim1234](https://www.ruby-forum.com/u/akramwasim1234)\
**Post date:** [August 31, 2009, 11:18am UTC](https://www.ruby-forum.com/t/creating-more-than-1-child-for-an-already-existing-parent/174671/3 "2009-08-31T11:18:17Z")

</div>

Hi Colin,

Yes, Consultancy has\_many :children

but what i want to do is creating many childrens in the same form for  
an already existing consultancy.

plz help me in this regard

---

<div class="post-metadata">

**Author:** ![akramwasim1234](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/b3f665/32.png) [@akramwasim1234](https://www.ruby-forum.com/u/akramwasim1234)\
**Post date:** [August 31, 2009, 11:27am UTC](https://www.ruby-forum.com/t/creating-more-than-1-child-for-an-already-existing-parent/174671/4 "2009-08-31T11:27:39Z")

</div>

2009/8/31 Kart [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid):

> Hi Colin,
> 
> Yes, Consultancy has\_many :children
> 
> but what i want to do is creating many childrens in the same form for  
> an already existing consultancy.

You want to look at Nested Forms I think. The rails guide Getting  
Started (I presume you have worked through the guides?) gives a brief  
introduction to this and google will provide many links.

Colin

---

<div class="post-metadata">

**Author:** ![akramwasim1234](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/b3f665/32.png) [@akramwasim1234](https://www.ruby-forum.com/u/akramwasim1234)\
**Post date:** [August 31, 2009, 11:56am UTC](https://www.ruby-forum.com/t/creating-more-than-1-child-for-an-already-existing-parent/174671/5 "2009-08-31T11:56:56Z")

</div>

2009/8/31 Kart [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid):

> thanks Colin
> 
> but The children is a single model(single DB table)
> 
> and what i want to do is create multiple instance of children from a  
> single form with validation for the child fields

That is what Nested Forms do. See section 9 in the getting started  
guide.

Colin

---

<div class="post-metadata">

**Author:** ![akramwasim1234](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/b3f665/32.png) [@akramwasim1234](https://www.ruby-forum.com/u/akramwasim1234)\
**Post date:** [August 31, 2009, 11:34am UTC](https://www.ruby-forum.com/t/creating-more-than-1-child-for-an-already-existing-parent/174671/6 "2009-08-31T11:34:06Z")

</div>

thanks Colin

but The children is a single model(single DB table)

and what i want to do is create multiple instance of children from a  
single form with validation for the child fields

but the normal new and create method doesn’t provide for creating  
multiple innstance of a model in single form ,It just provides  
creating a single instance

---

<div class="post-metadata">

**Author:** ![akramwasim1234](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/b3f665/32.png) [@akramwasim1234](https://www.ruby-forum.com/u/akramwasim1234)\
**Post date:** [August 31, 2009, 12:18pm UTC](https://www.ruby-forum.com/t/creating-more-than-1-child-for-an-already-existing-parent/174671/7 "2009-08-31T12:18:01Z")

</div>

You can see Railscasts #73, #74, #75 which deals with the same problem.  
Also searching on any search engine will also help.

–  
Thanks,  
Abhinav  
[http://twitter.com/abhinav](http://twitter.com/abhinav)

---

<div class="post-metadata">

**Author:** ![akramwasim1234](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/b3f665/32.png) [@akramwasim1234](https://www.ruby-forum.com/u/akramwasim1234)\
**Post date:** [August 31, 2009, 1:52pm UTC](https://www.ruby-forum.com/t/creating-more-than-1-child-for-an-already-existing-parent/174671/8 "2009-08-31T13:52:19Z")

</div>

Thanks a lot Colin …

---

<div class="post-metadata">

**Author:** ![akramwasim1234](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/b3f665/32.png) [@akramwasim1234](https://www.ruby-forum.com/u/akramwasim1234)\
**Post date:** [August 31, 2009, 1:52pm UTC](https://www.ruby-forum.com/t/creating-more-than-1-child-for-an-already-existing-parent/174671/9 "2009-08-31T13:52:55Z")

</div>

thanks a lot colin
