1)A user can have many causes and a cause can belong to many users.
2)A user can have many campaigns and campaigns can belong to many users. Campaigns belong to one cause.
I want to be able to assign causes or campaigns to a given user, individually. So a user can be assigned a specific campaign. OR a user could be assigned a cause and all of the campaigns of that cause should then be associated with a user.
Is that possible? And could I set it up so that the relationships could be simplified like so:
User.causes = all causes that belong to a user
User.campaigns = all campaigns that belong to user whether through a cause association or campaign association
I believe you should use the following:
This way you can use
You can read here about
has_and_belongs_to_manyrelationship, here abouthas_oneand here aboutbelongs_to.Let me know if this is what you want :]
Edit:
You can have a method on users model that returns all campaigns. Something like this: