# Finishing a lookup value

**URL:** <https://www.ruby-forum.com/t/finishing-a-lookup-value/98359>\
**Category:** Rails\
**Created:** [January 29, 2006, 12:46am UTC](https://www.ruby-forum.com/t/finishing-a-lookup-value/98359 "2006-01-29T00:46:19Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![craigrails](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/c2a13f/32.png) [@craigrails](https://www.ruby-forum.com/u/craigrails)\
**Post date:** [January 29, 2006, 12:46am UTC](https://www.ruby-forum.com/t/finishing-a-lookup-value/98359/1 "2006-01-29T00:46:19Z")

</div>

I have a form…2 tables and using auto\_complete

table clients  
id  
case\_manager\_id  
foreign key case\_manager\_id to case\_manager(id)

table case\_manager  
id  
name

my app/views/clients/\_form.rhtml includes which works (finally!)  
\<%= text\_area\_auto\_complete\_for :case\_manager :name %\>

and now in clients\_controller.rb

def create  
@client = Client.new(params[:client])

I need to add a line to this which gets the case\_manager.id from the  
case\_manager.name that I have already derived from auto\_complete and  
insert it into client.case\_manager\_id

I can’t figure this one out. Help?

Thanks

Craig

---

<div class="post-metadata">

**Author:** ![craigrails](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/c2a13f/32.png) [@craigrails](https://www.ruby-forum.com/u/craigrails)\
**Post date:** [January 29, 2006, 3:50am UTC](https://www.ruby-forum.com/t/finishing-a-lookup-value/98359/2 "2006-01-29T03:50:03Z")

</div>

On Sat, 2006-01-28 at 16:43 -0700, Craig W. wrote:

> insert it into client.case\_manager\_id
> 
> I can’t figure this one out. Help?

* * *

still working on this

@case\_manager = CaseManager.find\_by\_name( name )  
@client.case\_manager\_id = @case\_manager  
or  
@case\_manager = CaseManager.find\_by\_name( case\_manager[name] )  
@client.case\_manager\_id = @case\_manager

always gives me error "undefined local variable or method ‘[whatever is  
located inside the parens]’ "

I need to pull the case\_manager.id value into client.case\_manager\_id and  
I already have obtained the ‘name’ to match case\_manager.name from the  
auto\_complete on the form.

The Agile book doesn’t have anything similar and I’m apparently not  
smart enough to deduce how this is done.

Craig
