我想在第一行显示最后3个外观,然后我想显示所有其他外观,但没有最后3个外观。
这是我的密码
def index
query = params[:query].presence || "*"
conditions = {}
conditions[:available] = true
conditions[:look_tags] = params[:look_tags] if params[:look_tags].present?
@last_3_looks = Look.search query, where: conditions, order: { created_at: :desc }, limit: 3
@looks = Look.search query, where: conditions, order: { created_at: :desc }, page: params[:page], per_page: 8
end
问题是,如果我把偏移量如下,我有同样的8看每一页,如何处理呢?
@looks = Look.search query, where: conditions, order: { created_at: :desc }, page: params[:page], per_page: 8, offset: 3
end
2条答案
按热度按时间hsvhsicv1#
好像你想计算偏移量,比如:
但你也可以考虑使用卡米纳里宝石,这将使你的计算。似乎searchkick允许这样做。
另外,请看下面的答案。
rjee0c152#
只需从@looks中排除前3个结果(勾选第6行)