Last active
March 2, 2017 06:55
-
-
Save Teddybiers/777f2e0aa54bfaf4efde63a52fee0641 to your computer and use it in GitHub Desktop.
Map key and value after grouped in rails
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
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