Skip to content

Instantly share code, notes, and snippets.

@jparbros
Created December 10, 2015 18:22
Show Gist options
  • Select an option

  • Save jparbros/ea580960df6829b8b2e4 to your computer and use it in GitHub Desktop.

Select an option

Save jparbros/ea580960df6829b8b2e4 to your computer and use it in GitHub Desktop.
sent_user_ids = Message.where(sender_id: current_user.id).group(:receiver_id).pluck(:receiver_id)
received_user_ids = Message.where(receiver_id: current_user.id).group(:sender_id).pluck(:sender_id)
users_ids = sent_user_ids + received_user_ids - [current_user.id]
@users = User.where(id: users_ids)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment