http://railscasts.com/episodes/370-ransack?view=asciicastに従ってRansackを設定しましたが、orders#indexコントローラーを使用してOrdersテーブルのほとんどの列を検索できます。
ただし、他のモデルとのポリモーフィックな関連付けを格納する2つの列であるorderable_typeまたはorderable_idは検索されません。誰かが理由を知っていますか、またはこれをどのように回避しますか?
モデル:
class Order < ActiveRecord::Base
attr_accessible :quantity
belongs_to :orderable, polymorphic: true
belongs_to :delivery
belongs_to :requisition
コントローラ:
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"
そして、私が受け取るエラーは次のとおりです。
初期化されていない定数Order::Orderable抽出されたソース(行#13付近):
10:= f.text_field:location_place_matches 11:.field 12:= f.label:orderable_type_matches、 "Type" 13:= f.text_field:orderable_type_matches 14:.field 15:= f.label:created_at_gteq、 "Created between" 16 := f.text_field:created_at_gteq、'データの動作'=>'datepicker'
私の人生では、orderable_typeが他のすべての列とは異なる方法で処理されている理由がわかりません-誰かが修正するのを手伝ってもらえますか?