我将此行添加到我的.slim文件中:
= paginate cookies.permanent[:gyms].split('#').reverse, window: 1
然后,我得到此错误。所以我需要写一些配置?
我知道这与kaminari宝石有关。而且还没有关于cookie的模型。
日志信息为:
Completed 500 Internal Server Error in 137ms (ActiveRecord: 0.0ms)
ActionView::Template::Error (undefined method `total_pages' for #<Array:0x007f7d750d02d8>):
25: = link_to gym.split('+')[1] do
26: = gym.split('+')[3]
27: - temp_arr = cookies.permanent[:gyms].split('#').reverse
28: = paginate temp_arr, window: 1
29: //= render partial: "layouts/sidebar"
app/views/statics/history.html.slim:28:in `_app_views_statics_history_html_slim__1135090183647085502_70088407005100'
app/controllers/statics_controller.rb:168:in `history'
答案 0 :(得分:1)
您使用的是Array
,因此您应该使用Kaminari.paginate_array
方法:
https://github.com/kaminari/kaminari#paginating-a-generic-array-object