I have a Comment model obviously to make comments. I have also a
Person and Family class and I want to make comments on bother a person
and a family. How can I set this up. I want to use the same generic
comments table for all the comments on both person and family model. I
can’t figure it out, I can set up comments for either a Person or a
Family one at a time but not both.
Comment
person_id
Class Person
has_many :comments
How can I make comments work on the Family model too?
thanks you! polymorphic association it’s called you say. It works
now.
You might want to have a look at the acts_as_commentable plugin
It expands on this idea, but uses commentable rather than attachable
as the association name, which I think makes a bit more sense, and is
less likely to collide if you decide that one or more of the models
which can have comments can also have uploaded files as attachments.