0
我有一個filterrific作用域接受多個參數。範圍似乎正常運行(我可以在控制檯中調用Marketplace :: Lot.with_price({})並返回正確的結果),但是當我在表單上輸入信息時,filterrific不會傳遞任何數據。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在從未被擊中的範圍)。我應該注意到所有其他示波器正常工作。
我確定我錯過了一些明顯的東西,但是我找不到它爲我的生活。