I'm using searchkick gem and will_paginate gem.
i would like to make my search result page display n products for each category. For example when user search for "cat" it would display some thing like this..
item category
cat 1 image
cat 2 image
cat n image
item category
cat 1 video
cat 2 video
cat n video
... etc
page 1 2 3 (pagination)
right now my query is not efficient since i make each query for each category
@category1 = Listing.search(query,
where: { category: 1},
page: params[:page],
per_page: 30)
@category2 = Listing.search(query,
where: { category: 2},
page: params[:page],
per_page: 30)
what is the better approach ? thank u
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…