Last active
December 14, 2015 15:37
-
-
Save wstrinz/3a786bf7c47521f4ee50 to your computer and use it in GitHub Desktop.
get count of all models 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
Rails.application.eager_load! | |
getCounts = ->(model) { {model.to_s => model.try(:count) || "cant count" } } | |
ActiveRecord::Base.descendants.map(&getCounts) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment