From the Rails Guide, to establish a polymorphic relationship on one model, I need to add two columns for the corresponding table.
As the image below shows, the _id column is used as a foreign key. But I cannot figure out the usage of the _type column? What’s the usage of it?

The
_typecolumn is used to identify what resource this comes from. In this case, the polymorphic resource could be one ofEmployeeor aProduct. In other words: an image can relate to either a product or an employee.The
_typecolumn will simply contain the string of either “Employee” or “Product”. When this association is accessed, Rails will use it to know what model to use to load the associated object.