# Problem: insert data in two tables from an input form

**URL:** <https://www.ruby-forum.com/t/problem-insert-data-in-two-tables-from-an-input-form/92236>\
**Category:** Rails\
**Created:** [April 17, 2007, 11:16am UTC](https://www.ruby-forum.com/t/problem-insert-data-in-two-tables-from-an-input-form/92236 "2007-04-17T11:16:51Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![tuhin\_cse99](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/t/a6a055/32.png) [@tuhin\_cse99](https://www.ruby-forum.com/u/tuhin_cse99)\
**Post date:** [April 17, 2007, 11:16am UTC](https://www.ruby-forum.com/t/problem-insert-data-in-two-tables-from-an-input-form/92236/1 "2007-04-17T11:16:51Z")

</div>

Hi guys,  
I have two tables.  
Table1: output\_columns (3 columns)  
Table2: file\_datas (2 columns)  
In any table I can search, show, edit data. But how can I insert data in  
two table?  
In my input form there are 5 input fields. I want to input 3 data in  
table1 and last 2 data in table2. In the OutputColumnsController (the  
controller of table1) I have written the following code  
def create  
@output\_column = OutputColumn.new(params[:output\_column])  
if @output\_column.save  
flash[:notice] = ‘OutputColumn was successfully created.’  
redirect\_to :action =\> ‘list’  
else  
render :action =\> ‘new’  
end  
end  
By this code I can save in the table1. But how can I handle the  
input data in table2?  
Plz help me.

Amin

---

<div class="post-metadata">

**Author:** ![tuhin\_cse99](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/t/a6a055/32.png) [@tuhin\_cse99](https://www.ruby-forum.com/u/tuhin_cse99)\
**Post date:** [April 17, 2007, 4:41pm UTC](https://www.ruby-forum.com/t/problem-insert-data-in-two-tables-from-an-input-form/92236/2 "2007-04-17T16:41:03Z")

</div>

Hi guys,  
I have two tables.  
Table1: output\_columns (3 columns)  
Table2: file\_datas (2 columns)  
In any table I can search, show, edit data. But how can I insert data  
in  
two table?  
In my input form there are 5 input fields. I want to input 3 data in  
table1 and last 2 data in table2. In the OutputColumnsController (the  
controller of table1) I have written the following code  
def create  
@output\_column = OutputColumn.new(params[:output\_column])  
if @output\_column.save  
flash[:notice] = ‘OutputColumn was successfully created.’  
redirect\_to :action =\> ‘list’  
else  
render :action =\> ‘new’  
end  
end  
By this code I can save in the table1. But how can I handle the  
input data in table2?  
Plz help me.

Amin
