Using Rails 6.1.6 and Rails 2.7.0. and am following an article for adding pagination in Ruby using no gems. I'm running into a NameError exception for my Pagination module. Not certain if the naming of the hierarchy in the module is incorrect.
Pagination Helper
module PaginationHelper
def paginate(collection:, params: {})
pagination = Services::Pagination.new(collection, params)
[
pagination.metadata,
pagination.results
]
end
end
Jobs Controller
class JobsController < ApplicationController
include Pagination
JOBS_PER_PAGE = 8
def index
@pagination, @jobs = paginate(collection: Job.all, params: page_params)
end
Error Message NameError Exception
I've tried restarting the server to no avail. Am I missing something in the Pagination module?
CodePudding user response:
That should be include PaginationHelper
in your controller.
Or rename the helper to module Pagination
.