I am using pundit right now. But then in my controller, there is a search params with if condition, so I cannot simply use policy_scope to pass the pundit.
Posts_controller
def index
search = params['search']
if search.present?
@content = params['search']
@posts = Post.joins(:user).where("users.content ILIKE ?", "%#{@content}%")
else
@posts = Post.all
end
end
Pundit
def resolve
scope.all
end
I have try like @posts = PostPolicy::Scope.new(current_user, Post, @content).resolve , but it does not work.