# Creating a pulldown entry on the fly

**URL:** <https://www.ruby-forum.com/t/creating-a-pulldown-entry-on-the-fly/78091>\
**Category:** Rails\
**Created:** [December 27, 2005, 11:28pm UTC](https://www.ruby-forum.com/t/creating-a-pulldown-entry-on-the-fly/78091 "2005-12-27T23:28:37Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![afg](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/ecc23a/32.png) [@afg](https://www.ruby-forum.com/u/afg)\
**Post date:** [December 27, 2005, 11:28pm UTC](https://www.ruby-forum.com/t/creating-a-pulldown-entry-on-the-fly/78091/1 "2005-12-27T23:28:37Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![afg](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/ecc23a/32.png) [@afg](https://www.ruby-forum.com/u/afg)\
**Post date:** [December 29, 2005, 1:40am UTC](https://www.ruby-forum.com/t/creating-a-pulldown-entry-on-the-fly/78091/2 "2005-12-29T01:40:22Z")

</div>

On 12/28/05, Ed W [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) 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

---

<div class="post-metadata">

**Author:** ![afg](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/ecc23a/32.png) [@afg](https://www.ruby-forum.com/u/afg)\
**Post date:** [December 28, 2005, 12:30pm UTC](https://www.ruby-forum.com/t/creating-a-pulldown-entry-on-the-fly/78091/3 "2005-12-28T12:30:48Z")

</div>

> 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”
