Skip to content

Instantly share code, notes, and snippets.

@sandinist
Created April 20, 2012 09:56
Show Gist options
  • Save sandinist/2427434 to your computer and use it in GitHub Desktop.
Save sandinist/2427434 to your computer and use it in GitHub Desktop.
rake info:count
namespace :info do
desc "Count record each tables"
task(count: :environment) {
tables = ActiveRecord::Base.connection.tables
tables.reject!(&"schema_migrations".method(:==))
tables.map!(&:classify)
len = tables.map(&:length).max
tables.each{|table|
puts "#{table.ljust(len)}: #{Object.const_get(table).count}"
}
}
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment