current_page returns a string in 3.2
amirmujkic opened this issue · 4 comments
Hi,
It seems that in the latest version of will_paginate the current_page
was changed to a string.
Now it's
{"current_page"=>"1", "per_page"=>30, "total_entries"=>2, "total_pages"=>1}
instead of:
{"current_page"=>1, "per_page"=>30, "total_entries"=>2, "total_pages"=>1}
Perhaps someone can take a look at it
Thank you for reporting! Can you show us the code that generates the hash that you displayed that includes the "current_page"
key?
This could be related to #602
Here is mine.
This is my json api return,
render json: @listings.order('created_at DESC'),
include: '**',
each_serializer: ListingIndexSerializer,
meta: pagination(@listings)
and this is my helper method:
def pagination(collection)
{
current_page: collection.current_page,
next_page: collection.next_page,
previous_page: collection.previous_page,
total_pages: collection.total_pages,
total_entries: collection.total_entries
}
end
3.2 returns string but 3.1.x returns integer for current_page.
Please try https://github.com/mislav/will_paginate/releases/tag/v3.2.1
and if that doesn't work:
def pagination(collection)
{
- current_page: collection.current_page,
+ current_page: collection.current_page.to_i,
# ...
@mislav Sorry for the late reply, and thanks a lot for the quick fix!!! 🍻
I was using it in a very similar way as above
current_page: @paginated.current_page # @paginated is a `WillPaginate::Collection`
with the latest active_model_serializers
and json_api
adapter