how to use joins in scope in rails code example Example: rails how to use joins User.joins(:groups).where(groups: {id: 1})