Created
December 28, 2020 23:35
-
-
Save dsasse07/84e2d1a813e73e29e34c4b486c766b70 to your computer and use it in GitHub Desktop.
ActiveRecord group by count
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
Rental.group(:vhs).count #=> | |
#{<Vhs:0x00007f8d5e2bf0f0 id: 17, serial_number: "MAX-luqovgdk8e7tl", movie_id: 9 => 1, | |
#<Vhs:0x00007f8d4f81a4a0 id: 29, serial_number: "BABA-t6k24krzqclts", movie_id: 13 =>2, | |
#<Vhs:0x00007f8d4f854538 id: 11, serial_number: "BABA-begvxe7ai0rc6", movie_id: 13 =>3} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment