Let’s say
- User has many projects (projects created by user)
- User has many memberships
Also
- User has many joined_projects through memberships (projects created by other users)
What is the best way to join ‘projects’ and ‘joined_projects’ to get all the projects user has access to hopefully without using sql.
Other option would be creating membership for all projects even if user owns the project, but that generates duplicate data on the database.
The
joinmethod inActiveRelationalways uses inner joins, so there’s no way to do this “properly” from an SQL perspective. However, you can always set up acounter_cacheand query it like so:It might hit a normalization nerve but should get the job done.