search - IF conditions in rails is not executing -
i'm trying solr search based on text entered user. firts i've check whether entered text store or brand or category. after checking condition want display corresponding riesults in mainnavigationurls table using solr search. here controller action. working fine if enter store , can proper results. not going inside brands loop if storesearch found nill. please explain why not executing second case.
def search_all @storesearch=site.search fulltext params[:text] with(:multibrand,1) end if(@storesearch.nil?) @brandsearch=brand.search fulltext params[:text] end if(@brandssearch.nil?) @itemcategorysearch=maincategory.search fulltext params[:text] end @itemcategorysearch.results.each |result| @itemcategorysearch1=mainnavigationurl.search :main_categoty_id, result.id :department_id, params[:deptid].to_i paginate :page=>params[:page], :per_page=>45 end end else @brandsearch.results.each |result| @brandsearch1=mainnavigationurl.search :brand_id, result.id :department_id, params[:deptid].to_i paginate :page=>params[:page], :per_page=>45 end end else @storesearch.results.each |result| @storesearch1=mainnavigationurl.search :site_id, result.id :department_id, params[:deptid].to_i paginate :page=>params[:page], :per_page=>45 end end end end
instead of .nil? ,maybe can use .blank? better?
@array = [] @array.nil? -false @array.blank? -true
i think checking if @storesearch contain elements?
Comments
Post a Comment