Skip to content

Instantly share code, notes, and snippets.

@mrpunkin
Created February 22, 2012 23:26
Show Gist options
  • Save mrpunkin/1888336 to your computer and use it in GitHub Desktop.
Save mrpunkin/1888336 to your computer and use it in GitHub Desktop.
scope :voted_since, lambda{|since|
joins(:votes)
.where("`votes`.created_at >= ? AND `votes`.project_id = `users`.project_id", since.to_s(:db))
.group("`votes`.user_id")
.order("COUNT(`votes`.user_id) DESC")
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment