Is there any advantage of using polymorphic associations instead of
HABTM. Can anyone give me an example to explain.
has not much to do with each other
you would use polymorphic associations if you want to attach some kind
of information and functionality to several other tables/models
say for example you want to add image uploads to your app (which is some
social thing for car fans as example).
users can upload images of themselves
they can upload images of their cars
the data stored and upload functionality is just the same for cars or
users, so with polymorphic assocs you can just make both of them
habtm relations just define, that two tables are related in a they, that
each of them can be linked to many of the other kind
author has many books
books have many authors