データベース スキーマとそのコンテンツをレガシー サイトから Rails プロジェクトにインポートしました。
DVDと投票があります。投票は、 のような Dvd モデルの単純な整数フィールドDvd.votes:integer=10
です。
Since I can also associate new votes to users easily in Rails, I created a new Vote
model that belongs to Dvd
and User
models.
My situation is that now when calling Dvd.first.votes
I get an empty array [] since there's no data yet on the Vote model but the votes_count
still has the imported counts.
(I also renamed the Dvd.votes
field to Dvd.votes_count
after adding the Vote
model and added belongs_to :dvd, :counter_cache => true
on Vote model.)
I'm not sure what would be the ideal solution to this problem. Should I call votes by simply querying Dvd.votes_count
or there's a better way to do it?