pagination: fix paginator regression caused by Rails 7.

Fix the paginator not detecting the first or last page correctly during
sequential pagination.

Caused by the fact that we fetch one more record than needed to detect
whether we're on the last page, then throw that record away by
overriding Rails' internal `records` method. An upstream refactoring
meant that the `size` method now counts the number of records *after*
the extra record is thrown away, where before it counted *before* the
extra record was thrown away.
This commit is contained in:
evazion
2022-01-07 14:17:48 -06:00
parent 72ea78e697
commit cae6599631

View File

@@ -82,7 +82,8 @@ module PaginationExtension
when :sequential_before
false
when :sequential_after
size <= records_per_page
load
@records.size <= records_per_page
end
end
@@ -91,7 +92,8 @@ module PaginationExtension
when :numbered
current_page >= total_pages
when :sequential_before
size <= records_per_page
load
@records.size <= records_per_page
when :sequential_after
false
end