N:M:K Relationships


#1

Hello there,

I was wondering whether rails 1.1.1 supports N:M:K relationships that is
having a pivot table with three columns which are primary keys:

say, (apple_id, orange_id, lemon_id)

It would be so great if Rails could be able to have id-s which as
n-tuples.

Thanks,

Roland


#2

On Tue, Apr 18, 2006 at 09:21:51PM +0200, Roland M. wrote:
} Hello there,
}
} I was wondering whether rails 1.1.1 supports N:M:K relationships that
is
} having a pivot table with three columns which are primary keys:
}
} say, (apple_id, orange_id, lemon_id)
}
} It would be so great if Rails could be able to have id-s which as
} n-tuples.

I wouldn’t expect it to ever support n-way relationships directly. You
can,
however, do this:

AOL
belongs_to :apple
belongs_to :orange
belongs_to :lemon

Apple
has_many :aols

Orange
has_many :aols

Lemon
has_many :aols

Also, I believe you can use has_many :through to get to the other
objects
more directly.

} Thanks,
} Roland
–Greg