Polymorphic Associations
One of the more interesting offerings Active Record and Rails has on associations between tables is something called the Polymorphic Association. A polymorphic association is basically an association in which one model can ‘belong to’ two or more other models. So say if you have picture model that can either belong to an employee model or a product model, it can be done using active record polymorphic associations.

Active Record executes this association through a polymorphic belongs_to relationship. One can think of this declaration as an interface that any other model can use.

The migration can be simplified by using ‘t.references’.


Although this association isn’t the most commonly used, It’s still a very useful and very simple potential solution to have under your belt.
