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在从未被击中的范围)。我应该注意到所有其他示波器正常工作。
我确定我错过了一些明显的东西,但是我找不到它为我的生活。