Skip to content

how to use with polymorphic association? #514

Closed Answered by ddnexus
dcalixto asked this question in Q&A
Discussion options

You must be logged in to vote

You should use pagy_array only when you have an array of things that are already in memory. You don't use it for AR relations. Please, refer to the pagy_array doc for details about the reasons.

The pagination of any AR relation boils down to calling offset and limit on it, so getting a new paginated AR relation.

You can check whether pagination will work on your particular AR relation by trying in the console:

your_collection.offset(10).limit(10)

Then check also whether the count is correct:

your_collection.count(:all)

If that checks out then pagy should work with it out of the box.

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by dcalixto
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants