Last active
August 29, 2015 14:08
-
-
Save bernEsp/c2b4a6133f762548353b to your computer and use it in GitHub Desktop.
count all rows in rails app
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
(ActiveRecord::Base.send :subclasses).inject(0) do |sum, m| | |
begin | |
sum + m.all.size | |
rescue ActiveRecord::StatementInvalid | |
"no existe" | |
end | |
end | |
ActiveRecord::Base.each_model_class.inject .. add each model class method to active record module on base class |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
http://stackoverflow.com/questions/12701711/heroku-row-count-incorrect