0

I have a set of objects that I would like to paginate in a bit of a unconventional way. Some objects have a file attached and some don't. The behavior I would like is for the first set of objects without a file attached to be shown on the first set of pages and then for the objects with a file attached to be displayed on the following pages.

So if objects 1-10 have no attachments, and there are 8 objects viewed per page. I would like page one to have 8, and then page 2 to have only 2 objects, and the arrow to proceed to the next page. The remainder of the pages should paginate normally with the remaining objects with files attached, each with 8 per page.

I've looked at some code here: How to set different page size for the first page in Kaminari? This allows custom counts on the first page using padding, but haven't got it working correctly and wondering if there is a better solution.

cyboman
  • 41
  • 4
  • If you have a total of 20 objects, with 8 objects viewed per page, and 10 are with attachment, then help me divide them into the 3 pages so that I can understand your concern better. Also for the situation where only 6 are with attachment? – Gautam Feb 07 '20 at 03:16
  • Hi Guatam, thanks for your reply. I think I've figured this out. What I did was add a scope to the model for getting a count of those that have attachments. Then I did some math to determine the numbers left over for the last page of records w/o attachments. I then leveraged the use of offsets and limits as shown in the question I linked to get the desired effect. – cyboman Feb 07 '20 at 19:37

0 Answers0