(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. 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?