前提・実現したいこと
rails + redisのソート済みセット型 でPVランキング表示したいです。
今現在、詳細ページにアクセスすると、ランキングの変動もするのですが、
PV数(count)の表示が0のままです
該当のソースコード
posts
1 def index 2 @post = Post.all.order("created_at DESC") 3 4 ids = REDIS.zrevrangebyscore "posts/daily/#{Date.today.to_s}", "inf", 0, limit:[0, 2] 5 @ranking_posts = ids.map{| id |Post.find(id)} 6 end 7 8 def show 9 REDIS.zincrby "posts/daily/#{Date.today.to_s}", 1 ,@post.id 10 end 11
haml
1@ranking_posts.each do |post| 2 = post.title 3 = link_to "(#{post[1].to_i} PV)"
["8", 9.0],["6", 6]の9と6
["8",10.0],["6", 6.0]の10と6をviewで表示したいです
回答1件
あなたの回答
tips
プレビュー
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。