# Storing multiple of the same object from a request

**URL:** <https://www.ruby-forum.com/t/storing-multiple-of-the-same-object-from-a-request/127547>\
**Category:** Ruby\
**Created:** [January 30, 2008, 6:55am UTC](https://www.ruby-forum.com/t/storing-multiple-of-the-same-object-from-a-request/127547 "2008-01-30T06:55:44Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![laredotornado](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/l/9dc877/32.png) [@laredotornado](https://www.ruby-forum.com/u/laredotornado)\
**Post date:** [January 30, 2008, 6:55am UTC](https://www.ruby-forum.com/t/storing-multiple-of-the-same-object-from-a-request/127547/1 "2008-01-30T06:55:44Z")

</div>

Hi,

I have this form …

\<% for i in 1 … 5 %\>

| \<%= text\_field("ec\_line\_item", "prescription\_number", "index" =\> i) %\> | \<%= text\_field("ec\_line\_item", "description", "index" =\> i) %\> |
| Prescription Number | Description |

 \<% end %\>

Now on my controller end I would like to save the objects (each object  
is of class “ec\_line\_item” with attributes “prescription\_number” and  
“description”) but only if the prescription\_number attribute is not  
empty. What’s the most efficient way of doing this?

Thanks, - Dave

---

<div class="post-metadata">

**Author:** ![laredotornado](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/l/9dc877/32.png) [@laredotornado](https://www.ruby-forum.com/u/laredotornado)\
**Post date:** [January 30, 2008, 10:57pm UTC](https://www.ruby-forum.com/t/storing-multiple-of-the-same-object-from-a-request/127547/2 "2008-01-30T22:57:45Z")

</div>

On 1/30/08, laredotornado [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> ```
> <td><%= text_field("ec_line_item", "description", "index"
> 
> ```
> 
> Now on my controller end I would like to save the objects (each object  
> is of class “ec\_line\_item” with attributes “prescription\_number” and  
> “description”) but only if the prescription\_number attribute is not  
> empty. What’s the most efficient way of doing this?

First, this is really a question for the rails group.  
[http://groups.google.com/group/rubyonrails-talk/topics](http://groups.google.com/group/rubyonrails-talk/topics)

That said, you should check out Ryan B. series of 3 RailsCasts  
starting with:

> **[\#73 Complex Forms Part 1 - RailsCasts](http://railscasts.com/episodes/73-complex-forms-part-1)**
>
> Short Ruby on Rails screencasts containing tips, tricks and tutorials. Great for both novice and experienced web developers.

–  
Rick DeNatale

My blog on Ruby  
[http://talklikeaduck.denhaven2.com/](http://talklikeaduck.denhaven2.com/)
