I have a scenario where I need to have multiple has_one relationships and be able to access them all at once through a relationship.
Currently I have an STI table, we'll call it Animals. There are subclasses: Lion, Meerkat, Boar
And they all need to relate to multiple Group objects.
So a Lion can be in multiple groups, but a Group may only have one Lion related.
I want to limit and refer to specifically one Lion, Meerkat and Boar. I've tried a simple bridge table, has_many :animals, through: :associated_animals. But there doesn't seem to be an easy way to pull out group.lion. I've also tried doing multiple has_one :lion/:meerkat/:boar relationships, but there was no obvious way to do group.animals.
Is there an STI way to get this functionality through default rails associations or do I have to do a combination of both the has_one :lion and has_many :animals?