post votes: add index page.
This commit is contained in:
@@ -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
|
||||
|
||||
|
||||
Reference in New Issue
Block a user