I would like to select a user's groups where the join table is marked with favorit: true.
I have User which has Groups through a join table named UsersGroup. The UsersGroup model have the variables group_id and user_id, but also a variable favorit.
I would like to call the favorit groups of my users. But I don't know how to write it.
I've tried something like this :
current_user.groups.joins(:users_group).where(:users_group => { :favorit => true })
&
current_user.groups.where(users_group.favorit == true)
Do you have a solution for this kind of requests?