Unknown key(s): counter_cache
RoRアプリにカウンターキャッシュ列を実装しようとするとエラーが発生します。
この質問でモデルの関連付けを実装しました:モデルの関連付けの質問
これが私の移行です:
class AddVideoVotesCountToVideos < ActiveRecord::Migration
def self.up
add_column :videos, :video_votes_count, :integer, :default => 0
Video.reset_column_information
Video.find(:all).each do |p|
p.update_attributes :videos_votes_count, p.video_votes.length
end
end
def self.down
remove_column :videos, :video_votes_count
end
end
ただし、http://media.railscasts.com/videos/023_counter_cache_column.movを見た:counter_cache => true
後、後でVideoVoteモデルに移行する必要があるのではないかと思いましたbelongs_to :video
。ただし、これを行うと、次のエラーが発生します。
wrong number of arguments (2 for 1)
私は何が間違っているのですか?