Forum: Ruby on Rails STI and through

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.
Bruce D'Arcus (Guest)
on 2006-04-03 02:53
(Received via mailing list)
I'm trying to understand how to do the following, but am finding myself

I have three main tables; here are the first two:

CREATE TABLE reference_items (
  "id" integer primary key,
  "type" varchar(20),
  "title" varchar(255),
  "year" year(4)

CREATE TABLE "agents" (
  "id" integer primary key,
  "type" varchar(20),
  "sort_name" varchar(255),
  "description" text

So I've got ReferenceItem and Agent classes, each of which has
subclasses (for
the first, stuff like Book, Article, etc.).

The third key table links the above:

CREATE TABLE contributors (
  "reference_item_id" integer,
  "agent_id" integer,
  "position" integer,
  "type" varchar(20)

The Contributor class currently has four subclasses: Author, Editor,
and Translator. So the idea is I need to be able to separely track the
type and
order of each class.

So how do I get this correctly setup in my models? Or can I?

This topic is locked and can not be replied to.