From many to one to many to many with data on the join table

Hey,

I am transitioning a many to one relation to a many to many. We have a users and a teams schema at the moment. And we want to allow users to join multiple teams, instead of the currently allowed one.

I am thinking to add a users_teams table that could hold the ids of the respective tables and some additional info like role, status, default(marks default team of user).

Now this will require me to do user.users_teams.team. I know I could do a :join_through to have user.teams but with this I would miss the other info.

What would be cool is if when I load this relation in, I could have the role, status, etc info on the team level.

Is there a way to achieve that?

Thank you

1 Like