Skip to content
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

Fix next_cursor/previous_cursor for empty pages #6

Merged
merged 1 commit into from
May 15, 2024

Conversation

JProgrammer
Copy link
Contributor

This addresses an issue that getting next_cursor when has_next? is false that would raise a NoMethodError

NoMethodError: undefined method `[]' for nil
    lib/activerecord_cursor_paginate/cursor.rb:12:in `block in from_record'
    lib/activerecord_cursor_paginate/cursor.rb:12:in `map'
    lib/activerecord_cursor_paginate/cursor.rb:12:in `from_record'
    lib/activerecord_cursor_paginate/page.rb:81:in `cursor_for_record'
    lib/activerecord_cursor_paginate/page.rb:38:in `next_cursor'
    test/paginator_test.rb:285:in `test_empty_page'

@fatkodima fatkodima changed the title Return nil for cursor_for_record when record is nil Fix next_cursor/previous_cursor for empty pages May 15, 2024
@fatkodima fatkodima merged commit 7ad9771 into healthie:master May 15, 2024
4 checks passed
@JProgrammer JProgrammer deleted the fix-nil-cursor_for_record branch May 15, 2024 21:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

4 participants