Forum: Ruby on Rails selecting from dynamic pop-up list populated by a table

Announcement (2017-05-07): is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see and for other Rails- und Ruby-related community platforms.
Craig W. (Guest)
on 2006-01-26 02:24
(Received via mailing list)
I'll try again...

I am looking at this page...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

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

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

and this line generates error...
undefined local variable or method `case_manager' for

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
This topic is locked and can not be replied to.