-
Notifications
You must be signed in to change notification settings - Fork 3
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Collection is NOT displayed if count of items equals 1 #9
Comments
Thanks for opening this issue. Can you write a failing test that demonstrates the problem and send it in a pull request? (Actually a pull request with the solution as well would be much appreciated as I am a bit overwhelmed by other projects right now. 😄 ) |
Oh man it's been a while, sorry for neglecting this issue. Is this still a problem for you? |
Yes i still have problem with this issue. Now i have such bug workaround: MAX_PER_PAGE = 100 # max per page in paginator
def get_max_per_page_for(count)
# bug work around for CleanPagination
return MAX_PER_PAGE if count == 0
return 1 if count == 1
count < MAX_PER_PAGE ? count - 1 : MAX_PER_PAGE # because not visible for less count
end
def index
count = Event.count
if count == 0
render json: { result: 'no any events' }
return
end
paginate count, get_max_per_page_for(count) do |limit, offset|
render json: {
events: Event.all.limit(limit).offset(offset).as_json()
}
end
end |
Certainly if max_page = 0 it won't show any results because this specifies that the maximum results per page is zero. However I'm not able to reproduce the bug you reported where the response count is 1 but no results are served. I created a test here which demonstrates that your block will be called with limit=1 and offset=0. Also note that I created a pull request (#11) to make it so you don't have to make a special case for count=0. Can you please review my test to see if I understood your bug correctly? |
if companies.count is 1 request return JSON with one item but it is NOT displayed on client.
max_page can be 0,1 or 2 - no any effect
The text was updated successfully, but these errors were encountered: