Forum: Ruby on Rails HABTM - How do I do a select box for this?

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.
Gaudi (Guest)
on 2006-05-10 18:04
I've got several habtm's working fine in my app but have been having
trouble with a new twist: imagine an app that tracks students and
courses that they're taking.  So there's a student Class and a course
Class, and the tables also, and a students_courses table.  This stuff I
have down cold.

The problem was I wanted a form that allowed associating a student with
up to three courses, each individually selected from a drop-down select

Student:  John
Course 1:  (select box)
Course 2: (select box)
Course 3: (select box)

I tried the following for my select box code in my view (this is
pseudo-code, I don't have the source with me):

<% select :student, :course_id, Course.find(:all) %>

The error I'm getting is with the second parameter above.  I think I've
got that wrong.  Is there any way to do what I'm doing?  I think the
problem is that I don't understand how to modify a collection of many
courses when I've got three separate select boxes.  Thanks very much.
This topic is locked and can not be replied to.