将 pg 搜索添加到索引页但有专家问题

adding pg search to index page but having pundit issues

我正在尝试将 pg 搜索添加到我的推文索引页面,以搜索推文和用户,但是我在搜索时遇到了一些专家问题。我试图在索引页面上将我的推文政策设置为 return true 但没有任何变化。我试图查看专家文档,但我似乎找不到任何东西。谢谢。编辑:我在索引方法中添加了授权@tweet,但仍然不起作用

class Tweet < ApplicationRecord
  belongs_to :user
  acts_as_votable
  validates :content,
    presence: true,
    length: {maximum: 50},
    on: :create,
    allow_nil: false

    include PgSearch
  pg_search_scope :global_search,
    against: [ :content ],
    associated_against: {
      user: [ :first_name, :last_name , :username]
    },
    using: {
      tsearch: { prefix: true }
    }
end

<%= form_tag tweets_path, method: :get do %>
  <%= text_field_tag :query,
    params[:query],
    class: "form-control",
    placeholder: "Find a tweet or user"
  %>
<% end %>

   def index
    # @tweets = Tweet.all.order("created_at DESC")
    # @tweets = policy_scope(Tweet).paginate(page: params[:page], per_page: 7).order('created_at DESC')

    if params[:query].present?
      @tweets = Tweet.global_search(params[:query])
    else
    @tweets = policy_scope(Tweet).paginate(page: params[:page], per_page: 7).order('created_at DESC')

    end
    @tweet = Tweet.new
    @user = current_user
  end

class TweetPolicy < ApplicationPolicy
  class Scope < Scope
    def resolve
      scope.all
    end
  end

  def index?
    return true
  end

  def create?
    return true
  end

  def upvote?
    return true
  end

def downvote?
    return true
  end
  def update?
    record.user == user
    # - record: the restaurant passed to the `authorize` method in controller
    # - user:   the `current_user` signed in with Devise.
  end

  def destroy?
    record.user == user
  end
end

我明白了。我没有将策略范围添加到推文控制器索引方法中的 if else 语句的另一部分。