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
on 2009-02-09 15:36
on 2009-02-09 15:44
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.
on 2009-02-09 15:52
On Feb 9, 2009, at 9:43 AM, email@example.com 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 Biedenharn http://agileconsultingllc.com Rob@AgileConsultingLLC.com