Created
October 31, 2013 11:59
-
-
Save virajkulkarni14/7248519 to your computer and use it in GitHub Desktop.
Finding total number of rows in a database 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
st=0; ActiveRecord::Base.send(:subclasses).each {|sc| st += sc.all.size}; puts "Total number of rows is #{st.to_s}" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Also, this is useful:
http://api.rubyonrails.org/classes/ActiveRecord/Calculations.html