I have a Rails API app. I use Pagy nicely and works perfectly. However, I would like to call the same route|service|endpoint for getting all records, ignoring pagination. Is this possible?
Asked
Active
Viewed 66 times
1
-
1You could use a query params saying you want all records? – BTL Jan 11 '23 at 20:37
-
1Please post what your code does now (or some semblance of such) so people answering have something to work with when answering. – engineersmnky Jan 11 '23 at 20:44
2 Answers
0
You can pass a flag as query params and based on input you can set/ignore pagination

Hemangini Gohel
- 121
- 3
0
it would be able to work with an extra param, in this case we will use params[:show_all]
def index
unless params[:show_all]
@pagy, @products = pagy(Product.kept, items: page_size, page: page_number)
render json: @products
else
Product.kept
end
end

rnewed_user
- 1,386
- 7
- 13