ruby on rails 3 - how to write search method code to search more than one id at a time -
in project trying display products based on user choice. user can check department(women, men , kids) , category (dress, tops, tees etc) wish see. using check box. if user checks(selects) women departments products belongs women displayed. if user checks(selects) both women department , dress category products belongs both women department , dress category displayed. if user selects both women , men departments , shoes category products belongs women , men department , shoes category displayed. achieve using solr (sunspot gem). question can pass multiple ids department_id , category_id @ same time.
for example possible
@search_res=productdetail.search :department_id, 1,2,3 :category_id, 1,2,3,4, etc (may present or absent) end if possible please tell me how do? please give me syntax? please me.
update
thank salil answer, department id , category id's not static in case. came when user selects @ runtime. means category_id , department_id's generic. how achieve this. want this
@search_res=productdetail.search :department_id, params[:deptid] :category_id, params[:catid] end please me.
here is:
@search_res=productdetail.search all_of :department_id, [1,2,3] :category_id, [nil,1,2,3,4] # not sure - category_id nil should denote absence end end refer more info: sunspot readme
Comments
Post a Comment