Forum: Ruby on Rails last stupid question today

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.
D4b246038154d7cc2363256bd25a4fe0?d=identicon&s=25 Larry White (Guest)
on 2006-04-27 20:52
(Received via mailing list)
(well, from me anyway. I promise)

Trying to follow the "Self-referential Many-to-Many Relationships"
from the Rails Recipes book.

This is what I'm doing: Tasks can have a predecessor relationship with
other.  My Task class has this:

    has_and_belongs_to_many :predecessors,
      :class_name => "Task",
      :join_table => "predecessor",
      :association_foreign_key => "predecessor_id",
      :foreign_key => "task_id"

The join table predecessor looks like this:

CREATE TABLE predecessor (
    predecessor_id BIGINT NOT NULL,
    task_id    BIGINT NOT NULL

if I create two tasks t1 and t2 and make t2 a predecessor of t1 (like
t1.predecessors << t2),
then I can access t2 in memory ala t1.predecessors[0]. but calling save
t1 has no effect on
persisting the predecessor relationship and if I populate the join table
manually to create predecessors for t1,
t1.predecessors still returns [].

In my environment I have:
    ActiveRecord::Base.pluralize_table_names = false

and in any case I've tried both :join_table => "predecessor" , and
:join_table => "predecessors" with the same result.

what am i doing wrong?
This topic is locked and can not be replied to.