def matched_members
matched_members = []
availabilities.each do |availability|
matched_members << User.joins([:group, :availabilities]).where(["groups.id = ? AND users.id <> ? AND availabilities.next = ?", self.group.id, self.id, availability.next])
end
matched_members.flatten
end
Refactorings
No refactoring yet !
I'm trying to do a join between three tables with constraints and have it return a set of valid users back to me. While this code works as it should, it just seems very messy and I just think Rails would most likely have a very succinct way of doing this. Any ideas?