I have a class User, which has many Events and belongs to many Groups. I want to allow user to create Event and restrict who he wants the invite by Group, by user id or by both.
I am thinking creating a table Invitee to store all users’ id and events id. For each Event, when user A chooses to invite group Z and users B and C, I will query group Z to find all user id of the members and add them to Invitee table, together with B and C’s user id.
I think it is might not be the best way to do it. I wonder if there is a better way to do it.
Thank you.
Look in to polymorphic associations: basically you want invitations that can be either entity type.