class A
has_many :c
class B
has_many :c
class C
belongs_to :a
belongs_to :b
When I have an instance of C, its parent can be either A or B but I don’t know ahead of time which it is. Is there a simple way I can use Rails association to access the parent whichever it happens to be?
There are several ways you could do this, including polymorphism, but perhaps the most straightforward way is this: