My first ROR app is coming along nicely. This is definately a agile env. One of my last issues before inhouse deployment is creating pulldown entries on the fly. In particular, I'm writing a job tracking app for my company. We mostly do jobs for the same customers (law firms), so I have a pull down of law firms which is populated from a law_firms table. i.e assume only 2 tables for now: jobs and law firms. On the jobs new/edit form I want to have the ability to setup a new client law firm if they don't already exist. Is there a standard way to do this? I've created a "verify law firm" button that calls the :controller => law_firm, :action => list method. From there I don't have a nice way to get back to the job new/edit form. I guess I could put a link back to the form, but any data entry already done would be lost. Thanks Greg -- Greg F. The Norcross Group Forensics for the 21st Century
on 2005-12-28 00:28
on 2005-12-28 13:30
>already done would be lost. > > Your question is basically what I asked a few days ago. It's quite subtle really You can either stash some data in the session, or in a hidden field on the page, and then redirect around. The problem with putting it straight into the hash is that if your user is using two browser windows then the data starts overlapping so you probably want to think about putting the data in a hash in the session where the key is something unique and stashing the key in a hidden field If you stash the data on the form then you need to keep revalidating it because someone could alter it and post it back. If you stash it in the session then you need to figure out how to purge down the session data which accumulates from time to time... Bit of a pain either way! I guess other options would be to save it in the DB with an "incomplete" flag and then finalise the save when you get the law_firm id fields. Also, I think you could also just modify the existing form so that it has both jobs and lawfirms on the same page, then show/hide great chunks of the fields so that you can effectively jump from one to the other until you have all the data entered. This also means you can atomically commit everything quite easily and there is no serialisation required It's an interesting problem though. Would be interested to hear how you or others solve it Ed W P.S See previous posts about "multiple screens called before save"
on 2005-12-29 02:40
On 12/28/05, Ed W <firstname.lastname@example.org> wrote: > >I guess I could put a link back to the form, but any data entry > straight into the hash is that if your user is using two browser windows > > > P.S See previous posts about "multiple screens called before save" I think AJAX is effectively the same as your suggestion to have excess fields and hide the ones not in use. I will be trying to go that route, but I just got some user feedback and they want some added functionality prior to worrying about that aspect. Thanks Greg -- Greg F. The Norcross Group Forensics for the 21st Century