post votes: add index page.

This commit is contained in:
evazion
2019-10-28 03:21:18 -05:00
parent 754e3a2ee2
commit f4376fc7a3
9 changed files with 95 additions and 14 deletions

View File

@@ -23,6 +23,18 @@ class PostVote < ApplicationRecord
select_values_sql("select post_id from post_votes where score > 0 and user_id = ?", user_id)
end
def self.visible(user = CurrentUser.user)
return all if user.is_admin?
where(user: user)
end
def self.search(params)
q = super
q = q.visible
q = q.search_attributes(params, :post, :user, :score)
q.apply_default_order(params)
end
def initialize_attributes
self.user_id ||= CurrentUser.user.id