Search⌘ K
AI Features

Polymorphism in Other Frameworks

Explore how polymorphism is implemented in frameworks like ActiveRecord and Laravel, including their conventions and limitations. Understand why Ecto avoids this method due to integrity and performance concerns. Learn the fundamentals to implement polymorphic associations effectively in Ecto.

Some frameworks, notably ActiveRecord and Laravel, have a built-in convention to support polymorphic relationships. Here’s how we might follow that convention with our notes feature.

Make arrangements

Say that our notes table started with just the following two columns.

Field

Type

notes

text

author

string

To support polymorphism, we would add two more columns that would indicate the table name and ID of the record we want to attach the note to. When naming these columns, the convention is to use an ...