我如何指定一个 `associated_against` 一个在 pg_search 中有一个 `as: ` 名称的关联?

How do I specify an `associated_against` an association that has an `as: ` name in pg_search?

好的,所以我有一个具有这些关联的 Node 模型:

class Node < ActiveRecord::Base
  belongs_to :family_tree
  belongs_to :user
  belongs_to :media, polymorphic: true, dependent: :destroy
  has_many :comments, dependent: :destroy
end

关键关联是media,它实际上是Video的关联。这是我的 Video 模型的样子:

class Video < ActiveRecord::Base
  has_one :node, as: :media
end

但我不太明白如何在 pg_search_scope 中指定它。

我试过这个:

  include PgSearch
  pg_search_scope :node_search, against: [:name, :user_id, :circa, :cached_user_tag_list, :cached_tagged_user_names],
    using: { tsearch: { any_word: true, dictionary: :english, prefix: true} },
    :associated_against => {
      video: [:description, :title]
    }

但是我得到的错误是这样的:

Completed 500 Internal Server Error in 131ms (ActiveRecord: 41.6ms)    
NoMethodError - undefined method `table_name' for nil:NilClass:

所以当我尝试这种方式时:

  include PgSearch
  pg_search_scope :node_search, against: [:name, :user_id, :circa, :cached_user_tag_list, :cached_tagged_user_names],
    using: { tsearch: { any_word: true, dictionary: :english, prefix: true} },
    :associated_against => {
      media: [:description, :title]
    }

我收到这个错误:

Completed 500 Internal Server Error in 126ms (ActiveRecord: 17.7ms)    
NameError - uninitialized constant Node::Media:

我如何指定该关联,或者这是 pg_search 不知道如何管理的边缘情况?

pg_search 的维护者提到无法通过 SQL 直接搜索多态关联,因此无法用于 pg_search - 。