In my application I’m trying to create a model (Groups), which will
allow me to save groups of objects from various tables under a common
name. For example, one record in this table could refer to a group of
users. Another could refer to a group of photos. How should I do this?
When I use has_many_through I have to specify the group_id as well as
the id for whatever object I am referring to. But if the other id could
refer to a photo, or a user, or another model, how do I setup this kind
of inheritance? Do I have multiple foreign key fields in the table that
links the two together? EX: group_id, user_id, photo_id etc. and leave
the fields not being used blank. Or does this cause an error because
they are indexes?
In my application I’m trying to create a model (Groups), which will
allow me to save groups of objects from various tables under a common
name. For example, one record in this table could refer to a group of
users. Another could refer to a group of photos. How should I do this?
When I use has_many_through I have to specify the group_id as well as
the id for whatever object I am referring to. But if the other id could
refer to a photo, or a user, or another model, how do I setup this kind
of inheritance? Do I have multiple foreign key fields in the table that
links the two together? EX: group_id, user_id, photo_id etc. and leave
the fields not being used blank. Or does this cause an error because
they are indexes?