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

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.
2b2c2a705ed12f8fb327c7b4c56456c6?d=identicon&s=25 Sean Hussey (seanhussey)
on 2005-12-12 05: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?

Thanks!

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