# Forms that mix new and old records

**URL:** <https://www.ruby-forum.com/t/forms-that-mix-new-and-old-records/159867>\
**Category:** Rails\
**Created:** [February 9, 2009, 3:36pm UTC](https://www.ruby-forum.com/t/forms-that-mix-new-and-old-records/159867 "2009-02-09T15:36:59Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![casper\_the\_ghost](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/58956e/32.png) [@casper\_the\_ghost](https://www.ruby-forum.com/u/casper_the_ghost)\
**Post date:** [February 9, 2009, 3:36pm UTC](https://www.ruby-forum.com/t/forms-that-mix-new-and-old-records/159867/1 "2009-02-09T15:36:59Z")

</div>

I’m trying to create a form/view that displays a mix of records that  
exist in the database and records that the user is working on but that  
don’t yet exist in the database. I want to leverage all of rails’ nice  
form helpers, especially the params hash that it generates for the  
records when the form is submitted. So - I am creating ‘dummy’ records  
with fake ids to represent the new records that don’t really exist in  
the database.

I’m getting wrapped around the axle when I try and submit the form. I  
need to identify the pre-existing records and just save them back to  
the database with any modified data. For the new records, I need to  
create them fresh and then save them to the database.

I’ve been trying all sorts of clever tricks to identify the new  
records based on their fake ids, but I keep running into difficulties.  
I’m wondering if there is a simple convention for handling this  
scenario that I am missing, or if this is just one of those scenarios  
that requires a lot of work to make it work properly.

Any guidance would be appreciated.

Yoram

---

<div class="post-metadata">

**Author:** ![casper\_the\_ghost](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/58956e/32.png) [@casper\_the\_ghost](https://www.ruby-forum.com/u/casper_the_ghost)\
**Post date:** [February 9, 2009, 3:44pm UTC](https://www.ruby-forum.com/t/forms-that-mix-new-and-old-records/159867/2 "2009-02-09T15:44:03Z")

</div>

I should add that I feel that I have a reasonable mechanism for  
identifying ‘old’ record ids vs. ‘new’ record ids. It works great  
except for when the user uses the back button and resubmits the form.  
So - perhaps what I really need is a mechanism for avoiding double-  
submits.

---

<div class="post-metadata">

**Author:** ![casper\_the\_ghost](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/58956e/32.png) [@casper\_the\_ghost](https://www.ruby-forum.com/u/casper_the_ghost)\
**Post date:** [February 9, 2009, 3:52pm UTC](https://www.ruby-forum.com/t/forms-that-mix-new-and-old-records/159867/3 "2009-02-09T15:52:54Z")

</div>

On Feb 9, 2009, at 9:43 AM, removed\_email\_address@domain.invalid wrote:

> > don’t yet exist in the database. I want to leverage all of rails’  
> > create them fresh and then save them to the database.  
> > Yoram  
> > Do your “fake” IDs all begin with something like ‘new\_’?

-Rob

Rob B. [http://agileconsultingllc.com](http://agileconsultingllc.com)  
removed\_email\_address@domain.invalid
