Skip to content

Instantly share code, notes, and snippets.

@swr
Created February 5, 2010 23:07
Show Gist options
  • Save swr/296360 to your computer and use it in GitHub Desktop.
Save swr/296360 to your computer and use it in GitHub Desktop.
User.all.each { |p| User.update_counters p.id, :recipes_count => -p.recipes_count, :comments_count => -p.comments_count }
User.all.each { |p| User.update_counters p.id, :recipes_count => p.recipes.length, :comments_count => p.comments.length }
Recipe.all.each { |p| Recipe.update_counters p.id, :ratings_count => -p.ratings_count, :comments_count => -p.comments_count }
Recipe.all.each { |p| Recipe.update_counters p.id, :ratings_count => p.ratings_count.length, :comments_count => p.comments.length }
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment