Counter-cache AFTER database already populated

Kad,

If you want to initialize the counter cache after having modified the
db schema, simply run set the value in the migration like:

class AddArticlesCounterCache < ActiveRecord::Migration
  def self.up
    add_column :blogs, :articles_count, :integer

    for blog in Blog.find(:all) do
      blog.articles_count = blog.articles.size
      blog.save
    end
  end

  def self.down
    remove_column :blogs, :articles_count
  end
end

Alain