Last active
April 5, 2018 00:10
-
-
Save MyklClason/fdce6e48274f669d71b3233b4fc534e9 to your computer and use it in GitHub Desktop.
Get counts of all model records in the database via Ruby code (can be used in the console). Useful for determining what's using up heroku database row limits.
This file contains hidden or 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
Rails.application.eager_load! | |
ActiveRecord::Base.descendants.map { |m| [m.name, m.all.size] }.sort_by { |m, s| -s } | |
# Print on seperate lines | |
# puts ActiveRecord::Base.descendants.map { |m| [m.name, m.all.size] }.sort_by { |m, s| -s }.map(&:inspect) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment