module CrazyDb
Constants
- VERSION
Public Class Methods
db_statistics()
click to toggle source
Your code goes hereā¦
# File lib/crazy_db.rb, line 4 def self.db_statistics db_instance = ActiveRecord::Base.connection.tables html = "" html = html + "DATABASE NAME - #{Rails.configuration.database_configuration[Rails.env]["database"]}<br /><br />" html = html + "TOTAL NUMBER OF TABLES - #{db_instance.count}<br /><br />" html = html + "TABLE NAMES WITH TOTAL RECORDS COUNT<br />" count = 1 db_instance.each do |table| begin html = html + "#{count}. <b>#{table}:</b> <i>#{table.classify.constantize.count} Records</i><br />" count+=1 rescue end end return html.html_safe end