Skip to content

Instantly share code, notes, and snippets.

@rubypanther
Forked from mrpunkin/gist:1888336
Created February 22, 2012 23:33
Show Gist options
  • Save rubypanther/1888372 to your computer and use it in GitHub Desktop.
Save rubypanther/1888372 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