Forum: Ruby on Rails finishing a lookup value

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
C1e5a9e9344b6d31b9df7303e6dc378a?d=identicon&s=25 Craig White (Guest)
on 2006-01-29 00:46
(Received via mailing list)
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
C1e5a9e9344b6d31b9df7303e6dc378a?d=identicon&s=25 Craig White (Guest)
on 2006-01-29 03:50
(Received via mailing list)
On Sat, 2006-01-28 at 16:43 -0700, Craig White 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
This topic is locked and can not be replied to.