Skip to content

Instantly share code, notes, and snippets.

@domgetter
Created July 7, 2014 17:33
Show Gist options
  • Save domgetter/35e67806cf2a4d3acbda to your computer and use it in GitHub Desktop.
Save domgetter/35e67806cf2a4d3acbda to your computer and use it in GitHub Desktop.
names = Car.uniq.pluck(:name)
wheel_counts = Car.uniq.pluck(:wheels)
groups = []
names.each do |name|
wheel_counts.each do |wheel_count|
groups << Car.where(name: name, wheel: wheel_count)
end
end
groups.each do |group|
group.count
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment