Forum: Ruby on Rails How to populate join tables?

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.
hgs (Guest)
on 2005-11-12 13:49
(Received via mailing list)

class CseModule < ActiveRecord::Base
  has_and_belongs_to_many :students
  belongs_to :staff

class Student < ActiveRecord::Base
  has_and_belongs_to_many :cse_modules

Why doesn't

      # This next line should sort out the join table.
      @student_modules.each do |student, modules|
        the_student = Student.find_pnumber(student.pnumber)
        modules.each do |cse_module|
          the_cse_module = CseModule.find_aos_code(cse_module.aos_code)
          the_cse_module.students << the_student

leave any data in the join table cse_modules_students ?
According to my understanding of pages 240-241 of Agile Web
development it should.  I don't get any exceptions thrown.  I didn't
get errors about nonexistent tables being accessed.

        Thank you,
This topic is locked and can not be replied to.