Skip to content

Commit

Permalink
Docs: add troubleshooting - slow page help
Browse files Browse the repository at this point in the history
* Due to: #704
  • Loading branch information
benkoshy committed May 24, 2024
1 parent daece46 commit ca3ec58
Showing 1 changed file with 27 additions and 0 deletions.
27 changes: 27 additions & 0 deletions docs/troubleshooting.md
Original file line number Diff line number Diff line change
Expand Up @@ -79,4 +79,31 @@ In the specific `bootstrap` example you could override the default bootstrap `"p

!!!

==- Slow Last Page

There has been a report of a slow last page that has not been reproduced ([#696](https://github.com/ddnexus/pagy/pull/696)).

If you experience this rare case, try the following:


```rb
## override pagy_get_items
def pagy_get_items(collection, pagy)
collection.offset(pagy.offset).limit(pagy.in)
end
```

!!!warning Will not work with MS SQL Server

If you are using MS SQL Server and there is a possibility of having a collection with zero items, then the above [will throw an exception](https://github.com/ddnexus/pagy/issues/704).

In those cases, consider the following:

```rb
## override pagy_get_items
def pagy_get_items(collection, pagy)
collection.offset(pagy.offset).limit(pagy.in > 0 ? pagy.in : pagy.items )
end
```
!!!
===

0 comments on commit ca3ec58

Please sign in to comment.