在我们的 rails 3.2.8 应用程序中,当单击下一页或第 1 页之后的另一个页面时,will_paginate 会导致 ActiveRecord::RecordNotFound 错误。这是错误:
ActiveRecord::RecordNotFound in LeaseBookingsController#show
Couldn't find LeaseBooking with id=search_results
Parameters:
{"page"=>"4",
"id"=>"search_results"}
search_results 是控制器中的自定义操作:
def search_results
@lease_booking = LeaseBooking.new(params[:lease_booking], :as => :roles_search)
@lease_bookings = @lease_booking.find_lease_bookings.paginate(:per_page => 40, :page => params[:page])
end
find_lease_bookings 是模型中检索lease_booking 记录的方法。该错误仅与 will_paginate 相关。在 gemfile 中有:
gem 'will_paginate', '~> 3.0'
任何解决分页问题的解决方案?谢谢。