rails
counter_casheを使ってPostに紐付くCommentの数をDBカラムに保存するように修正した。 PostにCommentが追加/削除されたらCommentの数が変更される。 class Comment < ActiveRecord::Base belongs_to :post, :counter_cache => :comments_count end 上記の変…
counter_casheを使ってPostに紐付くCommentの数をDBカラムに保存するように修正した。 PostにCommentが追加/削除されたらCommentの数が変更される。 class Comment < ActiveRecord::Base belongs_to :post, :counter_cache => :comments_count end 上記の変…