# Multiple Models in one submit

**URL:** <https://www.ruby-forum.com/t/multiple-models-in-one-submit/129866>\
**Category:** Rails\
**Created:** [February 22, 2008, 6:11am UTC](https://www.ruby-forum.com/t/multiple-models-in-one-submit/129866 "2008-02-22T06:11:57Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![bitsmith](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/b/9de053/32.png) [@bitsmith](https://www.ruby-forum.com/u/bitsmith)\
**Post date:** [February 22, 2008, 6:11am UTC](https://www.ruby-forum.com/t/multiple-models-in-one-submit/129866/1 "2008-02-22T06:11:57Z")

</div>

I have an application which keeps track of my financial data. Each  
bank transaction I make is stored as an Entry model. An entry just  
has a name and an amount.  
I keep the text\_field for name and amount inside of a partial called  
\_entry.haml

I have a separate page for creating a new entry and editing an entry,  
both using this partial. The edit page correctly pre-populates the  
name and amount fields.

I want to add the ability for my app to import entries from a csv. In  
step one, I select the file and click go. In step two, I receive the  
file in my controller via @parsed\_file =  
CSV::Reader.parse(params[:csvfile])  
I iterate through parsed\_file and create an array of Entries like so:  
counter = 0  
@parsed\_file.each do |row|  
entry = Entry.new  
entry.description = row[1]  
entry.amount = row[3]  
@csvdata[counter] = entry  
counter += 1  
end

In my view I iterate over the @csvdata array:

- for entry in @csvdata  
%div= render :partial =\> “entry/entry”, :locals =\> { :entry =\>  
entry }

The entry partial is rendered, however, the entries are not pre-  
populated! The names given to all my HTML Form elements are the same!

1. How do I get the partials to pre-populate my form elements?
2. If I wrap all these form elements into a form, how would I process  
them when the next controller action receives this data?

Thank you for any information you can give!
