Hacktoberfest 2026: the issues maintainers tagged for October, open and beginner-friendly. Browse Hacktoberfest issues

undefined method `calculate_page_count' for nil:NilClass

Open
#1,284 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
2/5
Estimated time
1-3 hours
Newbie friendliness
35/100
Issue type
Bug
Clarity
Clearly specified
Activity status
Stale
Tech stack
ruby
Domain
api, backend

Research direction

Start in lib/jsonapi/processor.rb at the referenced line and reproduce the configuration with a resource using paginator :none and page-count metadata enabled. Confirm the request no longer raises undefined method `calculate_page_count' for nil:NilClass and that the response metadata remains correct.

Written by the indexing model from the issue text.

Description

https://github.com/cerebris/jsonapi-resources/blob/41df1475876dd7cfa3459e9cf0241a82e71c59c9/lib/jsonapi/processor.rb#L89

Configuration for JSONAPI http://jsonapi-resources.com/v0.8/guide/configuration.html

JSONAPI.configure do |config|

# :none, :offset, :paged, or a custom paginator name

config.default_paginator = :paged
config.default_page_size = 10
config.maximum_page_size = 50config.top_level_meta_include_record_count = true
config.top_level_meta_record_count_key = :record_count
config.top_level_meta_include_page_count = true
config.top_level_meta_page_count_key = :page_count
end

class ContactResource < BaseResource
attributes :name, :email

paginator :none
end

When paginator is set to :none in resource level, Then it shows undefined method `calculate_page_count' for nil:NilClass

solution:
https://github.com/cerebris/jsonapi-resources/blob/41df1475876dd7cfa3459e9cf0241a82e71c59c9/lib/jsonapi/processor.rb#L89

if (paginator && JSONAPI.configuration.top_level_meta_include_page_count && record_count)
page_count = paginator.calculate_page_count(record_count)
end

Dominant language
Ruby
Stars
2.3k
Forks
546
PR merge metrics
No merged PRs in 30d

Getting set up

We have not checked this project's setup files yet. Start from its README, and see our first-contribution guide for the general steps.

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from JSONAPI-Resources/jsonapi-resources

All issues in JSONAPI-Resources/jsonapi-resources

Similar issues

More Ruby issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.