# Single form multiple table

**URL:** <https://www.ruby-forum.com/t/single-form-multiple-table/184616>\
**Category:** Rails\
**Created:** [March 5, 2010, 7:24am UTC](https://www.ruby-forum.com/t/single-form-multiple-table/184616 "2010-03-05T07:24:04Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![M\_I\_R](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/839c29/32.png) [@M\_I\_R](https://www.ruby-forum.com/u/M_I_R)\
**Post date:** [March 5, 2010, 7:24am UTC](https://www.ruby-forum.com/t/single-form-multiple-table/184616/1 "2010-03-05T07:24:04Z")

</div>

Hi,  
I want to insert data into multiple database tables from a single  
form, look at the detail.

tables: patients, patient\_history, patient\_address,

first i will insert data into patient table and then the patient  
primary key will be used as foreign key in patient\_history and  
patient\_address from a single form. There is another issue that  
patient history will be multiple (ajax will be used to add multiple  
entries)

[http://www.thatsquality.com/examples/author-form](http://www.thatsquality.com/examples/author-form)

This example will give you the idea of adding multiple forms. It is  
for symfony which use the concept of embedded form which provide  
symfony. How will i add this functionlity in rails, please help.

---

<div class="post-metadata">

**Author:** ![M\_I\_R](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/839c29/32.png) [@M\_I\_R](https://www.ruby-forum.com/u/M_I_R)\
**Post date:** [March 5, 2010, 9:46am UTC](https://www.ruby-forum.com/t/single-form-multiple-table/184616/2 "2010-03-05T09:46:53Z")

</div>

On Fri, Mar 5, 2010 at 7:22 AM, M I R [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> entries)
> 
> [http://www.thatsquality.com/examples/author-form](http://www.thatsquality.com/examples/author-form)
> 
> This example will give you the idea of adding multiple forms. It is  
> for symfony which use the concept of embedded form which provide  
> symfony. How will i add this functionlity in rails, please help.

Hi,

Ryan B. did two episodes of Railscasts recently that will help you:

> **[\#196 Nested Model Form Part 1 - RailsCasts](http://railscasts.com/episodes/196-nested-model-form-part-1)**
>
> Short Ruby on Rails screencasts containing tips, tricks and tutorials. Great for both novice and experienced web developers.

> **[\#197 Nested Model Form Part 2 - RailsCasts](http://railscasts.com/episodes/197-nested-model-form-part-2)**
>
> Short Ruby on Rails screencasts containing tips, tricks and tutorials. Great for both novice and experienced web developers.

–  
Gael Muller
