Is it possible to have a model which belongs_to (either/or) more than one models?
For example, in my project I have a subscription model that may belong to a person or a group. When a person will join a particular group she automatically "inherits" the subscriptions of that group.
I have set up the following associations
In person.rb:
has_many :subscriptions
In group.rb:
has_many :subscriptions
In subscription.rb:
belongs_to :person
belongs_to :group
Also, I have added fields for person_id and group_id in the subscriptions table.
The problem is that when I try to create a subscription with let's say a person I get an error that the "Group must exist".
Is there a way to overcome this?
I would rather avoid using polymorphic associations if not absolutely necessary.