namespace :offerings do
  
  desc "recalculate the 'offerings_count' field for runnable objects"
  task :set_counts => :environment  do
    %w(Investigation ResourcePage Page Portal::Teacher).each do |c|    
      c.classify.constantize.all(:include => :offerings).each do |rec|
        rec.update_attribute(:offerings_count, rec.offerings.size)
      end
    end
  end
  
end
namespace :offerings do
  
  desc "recalculate the 'offerings_count' field for runnable objects"
  task :set_counts => :environment  do
    updating_models = %w(Investigation ResourcePage Page Portal::Teacher)
    
    updating_models.each_with_index do |c, i|    
      puts "Updating #{c.pluralize} (step #{i+1} of #{updating_models.size}) ..."
      c.classify.constantize.all.each do |rec|
        rec.update_attribute(:offerings_count, rec.offerings.count)
      end
    end
  end
  
end
Add friendly output to the offerings rake task
Add friendly output to the offerings rake task

The rake task to update the offerings count on some models was taking a long time when there was a lot of data.  This commit adds some debug output.