I have a STI class hierarchy like so:
Producer, Partner, Freelancer < Statusowner < Contact
When I call e.g. Partner.all
I see rails producing this:
SELECT "contacts".* FROM "contacts" WHERE "contacts"."type" IN ('Partner', 'Producer', 'Partner', 'Freelancer') ORDER BY contacts.name
You see that it first includes Partner, and then all Subclasses of Statusowner, including Partner again. This happens similarly with all subclasses.
I have set self.descentants
in Statusowner, so everything gets loaded early in the development environment:
class Statusowner < User
def self.descendants
[Producer, Sales, Partner, Freelancer]
end
end
Any idea what I am doing wrong?