In my app, I want to let users mark various relationship between them
and other users and objects. Example
john selects mary as favorite user
john selects mary as featured user of the month
john puts mary in bookmarks
john selects "funny cat" as favorite picture
john votes for "funny cat" as featured picture of the month
john puts "funny cat" in bookmarks
I could have a bookmark model, a favorite model, and a feature model
and use polymorphic association. But this seems like a lot of
duplication.
Thanks, I read the doc several times but I still don't get how I can
use it in my case. It seems I still need a separate join model for
favorite, bookmark, etc. ??
You may be able to use a combination of Single Table Inheritance and
polymorphic associations. STI would handle distinguishing bookmarks
from favorites from features, etc while allowing them all to share the
'mark' behavior. Polymporphic associations, as I think you already
understood, would allow you to 'mark' an object of any type.