2017-01-09
List and Count the Tables of your Rails App
The following Snippet will iterate over Tables and print out their total of
elements simply navigate to your rails project and run rails c:
ActiveRecord::Base.connection.tables.each do |table|
next if table.match(/\Aschema_migrations\Z/)
klass = table.singularize.camelize.constantize
puts "#{klass.name} has #{klass.count} records"
endNo more guesstimations ;-)
credits: Thomas E
← Previous Post | Next Post →