This is a simple but very useful way to assess the contents of your database.
desc "List model in application" task :list_models => :environment do Rails.application.eager_load! ActiveRecord::Base.descendants.each do |model| name = model.name count = model.count last_date = count == 0 ? 'no data' : model.order('updated_at desc').first.updated_at printf "%-20s %9d %s\n", name, count, last_date end end
No comments:
Post a Comment