简体   繁体   English

分页结果searchkick

[英]paginate results searchkick

So i have this pagination working on my tables 所以我的桌子上有这种分页

.page(params[:page]).per(50)

Heres what i have for my search 这是我要搜索的东西

@events = Event.search params[:search], suggest: true, partial: true, misspellings: {distance: 2}

if @events.results.any?
  render '/results'
else
  render '/noresults'
end

this is how i currently display it on my view 这是我目前在视图上显示它的方式

  <% @events.each do |event|%>

Thanks for any help! 谢谢你的帮助!

Sam 山姆

Pagination( As per the documentation) https://github.com/ankane/searchkick 分页(根据文档) https://github.com/ankane/searchkick

Plays nicely with kaminari and will_paginate. 与kaminari和will_paginate一起很好地玩。

# controller
@products = Product.search "milk", page: params[:page], per_page: 20

View with kaminari 用kaminari查看

<%= paginate @products %>

View with will_paginate 用will_paginate查看

<%= will_paginate @products %>

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM