votes: add is_deleted flag to post_votes table.

Add an is_deleted flag to post_votes so they can be soft-deleted in the future.
This commit is contained in:
evazion
2021-11-21 02:35:19 -06:00
parent 35c97d0836
commit be5173c8dd
3 changed files with 29 additions and 2 deletions

View File

@@ -12,6 +12,8 @@ class PostVote < ApplicationRecord
scope :negative, -> { where("post_votes.score < 0") }
scope :public_votes, -> { positive.where(user: User.has_public_favorites) }
deletable
def self.visible(user)
user.is_admin? ? all : where(user: user).or(public_votes)
end