Skip to content

Instantly share code, notes, and snippets.

@Teddybiers
Last active March 2, 2017 06:55
Show Gist options
  • Save Teddybiers/777f2e0aa54bfaf4efde63a52fee0641 to your computer and use it in GitHub Desktop.
Save Teddybiers/777f2e0aa54bfaf4efde63a52fee0641 to your computer and use it in GitHub Desktop.
Map key and value after grouped in rails
Model.group(:foo).count(:bar).each_with_object({}) do |(key, value), memo|
#if you want to modify key
key = "modified_key"
memo[key] = value
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment