How do you find relationships using has_and_belongs_to_m

You could do this. I'm sure there is a better way but if you use eager loading when pulling the current_user object from the database, the overhead shouldn't be bad.

@tasks = current_user.groups.each do |group|   @tasks << group.tasks end