我试图制作一个load more
按钮,一次只能加载4个项目。我正在使用will_paginate
和kaminari
。我正在使用当前代码收到错误:
1)我在加载页面并在控制器对象中有per_page
部分时遇到此错误:
undefined method 'to_model' for 2:Fixnum
<%= link_to 'show_more', @reservations_completed.next_page, :remote => true, :id => 'show_more_link' %>
@reservations_completed = current_user.reservations.where("turned_in = ?", true).where("completed_doc_updated_at <= due_date", true).order(created_at: :desc).paginate(:page => params[:page], :per_page => 4)
2)我也尝试了以下代码并收到此错误:undefined method 'last_page?' for
@reservations_completed = user.reservations.where("turned_in = ?", true).where("completed_doc_updated_at <= due_date", true).order(created_at: :desc).page(params[:page]).per_page(3)
<%= link_to_next_page @reservations_completed, 'show_more', :remote => true, :id => 'show_more_link' %>