From: darius Date: 2007-11-15T00:00:04+09:00 Subject: Re: why this rake db:migrate error Phlip wrote in news:Qpmdnb7bS_bDGKvanZ2dnUVZ_qGknZ2d@adelphia.com... > > The best forum for Rails questions is Ruby-on-Rails-talk, at Google > Groups. > thank you. I'll check it out. >> def self.up >> Story.find(:all).each do |s| >> s.update_attribute :votes_count, s.votes.length >> end >> end > > In a database, never store a value that you could also get thru a > query. That's a redundancy, and the best software always has the > fewest redundancies of any type. I would erase :votes_count from all > migrations, and just use votes.count. > I know. This was done to avoid a costly query.