Filter and Paginate
iainbryson opened this issue · 4 comments
Expected Behavior
Based on the docs, I figured that one would filter first, then paginate:
jsonapi_filter(resource_class.all, allowed_fields, options) do |filtered|
jsonapi_paginate(filtered) do |paginated|
render jsonapi: paginated, status: :ok
end
end
Actual Behavior
When I do this, I get this exception:
Minitest::UnexpectedError: NoMethodError: undefined method `size' for Ransack::Search<class: Article, base: Grouping <combinator: and>>:Ransack::Search
perhaps it's related to this commit 3a31499
Steps to Reproduce the Problem
Code above ☝️
Specifications
- Version: 1.6.0
- Ruby version: 2.7.2
@iainbryson thanks for reporting this, it does look like this is related to the 3a31499, do you have a more complete backtrack btw? It's strange that the tests passed... 🤔
@stas I just figured it out: it should be filtered.result
in the inner block. Now I'll do some extra testing, but it looks positive.
@stas it looks like the only issue I find is the meta.total
. It gets reported as the page size, regardless of the size of the underlying query. IIRC this should really be the size of the full query, not the paginated one.
@iainbryson we don't have total in the meta... We have meta.records
as of recently... Could you double check please?!