I’ve spent quite a lot of time messing around the methods for subtyping in ActiveRecord. The clearest method I’ve found is using concrete classes (what Fowler calls them). For this to work you simple have a inheritance relationship between the base type and the subclasses and have the AR attribute on all the classes (I get a weird error if the base class doesn’t have this attribute).
E.g.
[ActiveRecord(“BaseType”)]
public class BaseType
{}
[ActiveRecord(“FirstSubType”)]
public class FirstSubType:BaseType
{}
[ActiveRecord(“SecondSubType”)]
public class SecondSubType:BaseType
{}
You end up with a little bloat in terms of sourcefiles and database tables, but, at least you have a very clear subtyping relationship. I had wasted a lot of time with the AnyToAny relationship syntax. Note: There is no documentation whatsoever for how to use AnyToAny relationships in AR. I reccomend searching the Subversion repository test cases for examples of how to use that. Even the forums lacked any good description of how to code it. Honestly this is one of those features that I would almost switch to NHibernate if I can’t work it.