Has_many_and_belongs_to_many

I read this:
jrhicks.net

It is from 2005, so some of it has old screenshots (and it looks like
Windows).

Do I really create that third table on my own? Rails doesn’t
automagically create it?

I have students and parents. Students can have more than one parent
and a parent can have more than one student. So I have to create a
students_parents table to track the connections? How will rails know
it is that instead of a parents_students table?

Thanks,
–Colin

On 10/15/07, Colin S. [email protected] wrote:

I have students and parents. Students can have more than one parent
and a parent can have more than one student. So I have to create a
students_parents table to track the connections? How will rails know
it is that instead of a parents_students table?

Actually, rails would want a parents_students table, it puts the model
names in sort order.

And yes, you need to create the table, but nowadays you can use a
migration instead of hand coded sql

CreateParentsStudents < ActiveRecord::Migration

def self.up
    create_table :parents_students, :id => false do | t |
        t.column :parent_id, :integer
        t.column :student_id, :integer
    end

end

def self.down
drop_table :parents_students
end
end


Rick DeNatale

My blog on Ruby
http://talklikeaduck.denhaven2.com/

Okay, thanks. I did that. Perfect.

–Colin