Selecting from dynamic pop-up list populated by a table


#1

I’ll try again…

I am looking at this page…HowToUseFormOptionHelpers
http://wiki.rubyonrails.org/rails/pages/HowtoUseFormOptionHelpers

perhaps I should be using Ajax for this…I haven’t looked at Ajax yet.

Have 2 tables - clients & case_managers

I want the data from a column in case_managers to be the select list on
a screen for adding/editing clients as I am pretty sure that I have the
necessary things set up for relationship between the two tables.

class Client < ActiveRecord::Base
has_one :case_manager
end

app/views/clients/_form.html contains line…

<% collection_select("client", "case_manager_id", \ case_manager.find_all, "name", "id") %>

and this line generates error…
undefined local variable or method `case_manager’ for
#<#Class:0xb7b93f84:0xb7b93b88>

What should the collection_select statement look like for it to populate
a pop-up select list of the names column from case_managers table?

for reference;

clients table has defined…
id integer primary key not null
case_manager_id not null
foreign key (case_manager_id) references case_managers(id)

case_managers table has defined
id integer primary key not null
name character varying 53 not null
no foreign keys

case_managers_clients table has defined
client_id integer not null
case_manager_id integer not null
no primary key