class StaticProjectNews < ActiveRecord::Migration def up Project.all.each do |project| unless project.news.nil? news_count = project.news.count project.update_attribute(:news_count, news_count) end end end def down end end