Forum: Ruby on Rails Is this a good use for Single Table Inheritence?

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.
Sean H. (Guest)
on 2005-12-12 06:12
(Received via mailing list)
Hi everyone,

Where I work, there are several standards (heh) for position codes for
staff and faculty.  For instance, a Dean could be listed as DEA or
DEN.  An Assistant Professor could be AST or ASO.  There are some
cases where typos have crepts into the system, and AS0 (zero) could
have meant ASO.

Now, beyond getting those responsible to clean up their data (we are),
I need to deal with this now.  I was hoping Single Table Inheritence
would help me.

For all legit codes (you know, the ones IT standardized on), we could
have an id, code, and description.  Simple stuff:

id: 1
code: AST
description: Assistant Professor

For the discrepencies, there would be an additional column pointing to
the code it really is.

id: 2
code: ASO
description: <blank>
parent: 1  (A better name for this would be great, but you ge the idea.)

So, what would be the best way to apply a code to someone?  Write a
custom find_by_code that returns the code if it has no parent and the
parent code if it does?


This topic is locked and can not be replied to.