Sign in through GitHub

Please read for an updated status on RailsCasts:

Learn more or hide this

Sergey Alekseev's Profile

GitHub User: sergey-alekseev

Site: http://sergeyalekseev.by/

Comments by Sergey Alekseev

Avatar

Sorry, we can use .reset_counters:
Category.all.map(&:id).each { |id| Category.reset_counters(id, :products) }

Avatar

Specifying a counter cache will add it to that model’s list of readonly attributes using attr_readonly.

I think raw SQL within migration is the only option to update counter cache column.