2016-11-15 5 views
0

私は複数のパラメータを受け入れるフィルタリング範囲を持っています。スコープは正常に機能しているようです(コンソールでMarketplace :: Lot.with_price({})と呼ぶことができ、正しい結果を返します)、フォームに情報を入力すると、filterrificはデータを渡しません。ここでフィルタリング対象範囲に複数のパラメータを渡しません

はここでモデルの私filterrific宣言

filterrific(
    default_filter_params: { sorted_by: 'time_remaining_asc' }, 
    available_filters: [ 
     :with_price, 
     :sorted_by, 
     :lots_with_item_type, 
     :search_query 
    ] 
) 

である私のコントローラは、次のようになります。、私はフォームを送信すると

@filterrific = initialize_filterrific(
    Marketplace::Lot, 
    params[:filterrific], 
    select_options: { 
    sorted_by: Marketplace::Lot.options_for_sorted_by, 
    item_types: Marketplace::Lot.options_for_item_types 
    }, 
    persistence_id: 'marketplace_key', 
) or return 

@lots = @filterrific.find.paginate(page: params[:page], per_page: 20) 

と私の見解

<%= f.fields_for :with_price, OpenStruct.new(@filterrific.with_price) do |with_price_fields| %> 
    <div class="marketseach__shards shards"> 
     <%= with_price_fields.text_field :shards_min, class: 'marketplace__value input', placeholder: 'Low Value' %> 
     - 
     <%= with_price_fields.text_field :shards_max, class: 'marketplace__value input', placeholder: 'High Value' %> 
    </div> 
    <span class="marketsearch__text">or</span> 
    <div class="marketsearch__gems gems"> 
     <%= with_price_fields.text_field :gems_min, class: 'marketplace__value input', placeholder: 'Low Value' %> 
     - 
     <%= with_price_fields.text_field :gems_max, class: 'marketplace__value input', placeholder: 'High Value' %> 
    </div> 
    <% end %> 

価格フィールドはparamsハッシュに表示されます

"filterrific"=> 
{ "search_query"=>"Programming", 
    "lots_with_item_type"=>"", 
    "with_price"=>{"shards_min"=>"200", "shards_max"=>"", "gems_min"=>"", "gems_max"=>""}, 
    "sorted_by"=>"alpha_asc" 
}, 

しかし、決してスコープにはなりません(私は決してヒットしない範囲でbinding.pryを持っています)。他のすべてのスコープが正しく動作していることに注意してください。

私は確かに何かが分からないと確信していますが、私の人生のためにそれを見つけることはできません。

答えて

0

Filterrificには、複数のフィールドがスコープで渡されたときにエラーを返すバグがあります。現在のところ、プルリクエスト#116で修正されていますが、2011年12月24日にこの投稿の時点でマスターブランチにマージされていません...フィルタリック宝石を手動で更新すると、新しいリリースが投稿されるまで機能します...

https://github.com/jhund/filterrific/pull/116

ジョン

関連する問題