Forum: Ruby on Rails STI and through

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
3f2ae5bbf68f4b4d546b23b6b4087b54?d=identicon&s=25 Bruce D'Arcus (Guest)
on 2006-04-03 00:53
(Received via mailing list)
I'm trying to understand how to do the following, but am finding myself
stuck.

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,
Publisher,
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?

Bruce
This topic is locked and can not be replied to.