Finishing a lookup value


#1

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


#2

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