ruby on rails - Ransack search by multiple select(checkbox) on check -


shows no error in code, iam using ransak search ,but iam not getting search output. want output when check size option checkbox. if click medium ,i want display medium dresses,like please give me solution

this checkbox

enter image description here

here code

product/index.html.slim

= search_form_for @product_search, url: shop_index_path |f| = f.label :size_cont, "size available" - standardsize.all.each |s| = check_box_tag('product_search[standard_sizes_id_eq_any_cont][]', s.id ) = s.name

here shopcontroller.rb

class shopcontroller < applicationcontroller def index @product_search = product.ransack(params[:q]) @products = @product_search.result(distinct:true).page(params[:page]).per(8) @product_search.build_sort if @product_search.sorts.empty? end

model standardsize.rb

class standardsize < activerecord::base belongs_to :product end

here model product.rb

class product < activerecord::base has_and_belongs_to_many :standard_sizes end

this server getting started "/shop?utf8=%e2%9c%93&q%5bname_cont%5d=dress&q%5bprice_paisas_gteq%5d=&q%5bprice_paisas_lteq%5d=&product_search%5bstandard_sizes_id_eq_all%5d%5b%5d=3&commit=search" 10.0.2.2 @ 2015-07-23 10:12:42 +0000 cannot render console 10.0.2.2! allowed networks: 127.0.0.1, ::1, 127.0.0.0/127.255.255.255 processing shopcontroller#index html parameters: {"utf8"=>"✓", "q"=>{"name_cont"=>"dress", "price_paisas_gteq"=>"", "price_paisas_lteq"=>""}, "product_search"=>{"standard_sizes_id_eq_all"=>["3"]}, "commit"=>"search"} user load (0.1ms) selectusers.* fromuserswhereusers.id= 1 order byusers.idasc limit 1

unless you've configured ransack otherwise, search parameters should nested under @q. i've had success _in instead of _eq_any_cont.

replace

= search_form_for @product_search, url: shop_index_path |f|   = f.label :size_cont, "size available"   - standardsize.all.each |s|     = check_box_tag('product_search[standard_sizes_id_eq_any_cont][]', s.id )      = s.name 

with

= search_form_for @q, url: shop_index_path |f|   = f.label :size_cont, "size available"   - standardsize.all.each |s|     = f.check_box :standard_sizes_id_in, {multiple: true}, s.id, nil     = s.name 

Comments

Popular posts from this blog

javascript - Karma not able to start PhantomJS on Windows - Error: spawn UNKNOWN -

c# - Display ASPX Popup control in RowDeleteing Event (ASPX Gridview) -

Nuget pack csproj using nuspec -