Fix #3642: Issues with sequential pagination.

As of Rails 5, overriding `to_a` on an ActiveRecord collection does
nothing. We need to override `records` instead.

ref: cdd45fa09d
This commit is contained in:
evazion
2018-04-14 10:18:20 -05:00
parent 074b66bf27
commit d42ef7d7dc

View File

@@ -19,7 +19,10 @@ module Danbooru
end
end
def to_a
# XXX Hack: in sequential pagination we fetch one more record than we need
# so that we can tell when we're on the first or last page. Here we override
# a rails internal method to discard that extra record. See #2044, #3642.
def records
if sequential_paginator_mode == :before
super.first(records_per_page)
else