How can I ask ActiveRecord to make it’s “has_many” code to work on some
arbitrary relationship between two tables? ie neither field is a primary
key
The situation is that I am writing a Postfix management application and
one of the tables to manage is the “alias” table. My primary key in the
“mailbox” table is “id”, but the alias table is just a mapping between
two text email address fields. It needs to stay like this for
performance reasons and also because applications querying the DB are
not able to do table joins, finally it’s also because you can setup
aliases for things which aren’t in your database
So I would like to be able to navigate to my “mailbox” object and then
navigate down into the “aliases” collection from that object and find
any related aliases and also have all the nice methods that come as a
result of using the “has_many” macro
Any suggestions? (Or am I misunderstanding exactly what has_many
actually does?)
Thanks
Ed W