1
我在檢查用戶是否對給定的帖子進行投票,然後更改上下箭頭的樣式。 activerecord-reputation-system
寶石尚未在一段時間內更新,我發現每個例子都使用過時的代碼,或者需要分別跟蹤「向上」投票和「向下」投票。我更喜歡使用:post_votes
並檢查該參數的值。Activerecord聲望系統 - 如何檢查current_user的投票值
posts_controller.rb
@voted_items = Post.evaluated_by(:post_votes, current_user)
index.html.erb
<% if current_user && @voted_items.include?(post) %>
# display active up or down arrows
<% end %>
我怎麼只是@voted_items
對象中的相關記錄的價值?
編輯:我注意到沒有內置的範圍:value。也許手動添加一個會讓我查詢一個特定的值?