Created
January 29, 2014 18:50
-
-
Save gringocl/8694367 to your computer and use it in GitHub Desktop.
ActiveRecord query method chains
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
User.all.includes(:questions).map(&:question_ids).flatten.group_by { |n| n }.map { |k,v| [ k, v.size ] }.sort_by { |a| a.last }.each { |a| max = a.last if a.last > max }.select { |e| e.last == max } | |
User.all.map(&:question_ids).flatten.group_by { |n| n }.map { |k,v| [ k, v.size ] }.sort_by { |a| a.last }.each { |a| max = a.last if a.last > max }.select { |e| e.last == max } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment