Ruby on rails Ransack不使用多态列类型(未初始化常量)

Ruby on rails Ransack不使用多态列类型(未初始化常量),ruby-on-rails,ransack,Ruby On Rails,Ransack,我已经按照设置了Ransack,使用Orders#index controller搜索Orders表中的大多数列功能正常 但是,它不会搜索orderable_type或orderable_id,这两列存储与其他模型的多态关联。有人知道为什么吗,或者如何避开这个问题 型号: class Order < ActiveRecord::Base attr_accessible :quantity belongs_to :orderable, polymorphic: true belo

我已经按照设置了Ransack,使用Orders#index controller搜索Orders表中的大多数列功能正常

但是,它不会搜索orderable_type或orderable_id,这两列存储与其他模型的多态关联。有人知道为什么吗,或者如何避开这个问题

型号:

class Order < ActiveRecord::Base
  attr_accessible :quantity
  belongs_to :orderable, polymorphic: true
  belongs_to :delivery
  belongs_to :requisition
视图:

我收到的错误是:

未初始化的常量顺序::可排序的提取源(第13行附近):

10:=f.文本\字段:位置\位置\匹配11:.字段12:= f、 标签:可订购类型匹配,“类型”13:=f.text\u字段 :可订购\u类型\u匹配14:.字段15:=f.label :created_at_gteq,“created between”16:=f.text_字段 :在_gteq上创建,'data behavior'=>'datepicker'


就我个人而言,我不明白为什么它对待orderable_类型的方式与其他所有列的方式不同——有人能帮我解决吗?

我没有找到解决这个问题的方法,但一位开发人员朋友建议了一种方法,我可以获得同样的结果,这可能会帮助其他人。他说我应该只对表单字段进行硬编码,而不是依靠搜索助手来创建下拉菜单。这就是我所做的,而且它是有效的:-)

搜索多态关联的Ransack wiki可能会有所帮助:
  def index
    @search = Order.search(params[:q])
    @orders = @search.result
  end
= search_form_for @search do |f|
  .field
    = f.label :orderable_type_matches, "Type"
    = f.text_field :orderable_type_matches
  .field
    = f.label :created_at_gteq, "Created between"
    = f.text_field :created_at_gteq, 'data-behaviour' => 'datepicker'
    = f.label :created_at_lteq, "and"
    = f.text_field :created_at_lteq, 'data-behaviour' => 'datepicker'
  .actions
    = f.submit "Search"