search: refactor to pass in the current user explicitly.
This commit is contained in:
@@ -17,14 +17,14 @@ class ForumPostVote < ApplicationRecord
|
||||
all
|
||||
end
|
||||
|
||||
def self.forum_post_matches(params)
|
||||
def self.forum_post_matches(params, current_user)
|
||||
return all if params.blank?
|
||||
where(forum_post_id: ForumPost.search(params).reorder(nil).select(:id))
|
||||
where(forum_post_id: ForumPost.search(params, current_user).reorder(nil).select(:id))
|
||||
end
|
||||
|
||||
def self.search(params)
|
||||
q = search_attributes(params, :id, :created_at, :updated_at, :score, :creator, :forum_post)
|
||||
q = q.forum_post_matches(params[:forum_post])
|
||||
def self.search(params, current_user)
|
||||
q = search_attributes(params, [:id, :created_at, :updated_at, :score, :creator, :forum_post], current_user: current_user)
|
||||
q = q.forum_post_matches(params[:forum_post], current_user)
|
||||
q.apply_default_order(params)
|
||||
end
|
||||
|
||||
|
||||
Reference in New Issue
Block a user