Skip to content

Instantly share code, notes, and snippets.

@Spaceghost
Created February 8, 2012 22:35
Show Gist options
  • Save Spaceghost/1774929 to your computer and use it in GitHub Desktop.
Save Spaceghost/1774929 to your computer and use it in GitHub Desktop.
Question.where(
QuestionSkipCount.where(
question_id: Question.where(messages_count: 0).all.map(&:id), # 1.Returns all question id's for each question without a message
# Pending
).all # 2.Gets all question_skip_counts for each question that has no message
).all # 3.Gives all the questions that have no messages, and (soon) the least amount of skips.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment