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

Add require 'kaminari/helpers/helper_methods' in core.rb #1100

Merged
merged 2 commits into from
Sep 22, 2023

Conversation

hikonori07
Copy link
Contributor

@hikonori07 hikonori07 commented Mar 20, 2023

If you include this file(app/controllers/concerns/pagination.rb) in a controller that wants to paginate, an "uninitialized constant" error will occur.

NameError: uninitialized constant Kaminari::Helpers::UrlHelper

app/controllers/concerns/pagination.rb

module Pagination
  extend ActiveSupport::Concern
  include Kaminari::Helpers::UrlHelper

  included do 
    def resources_with_pagination(resources)
      pagination = {
        pagination: {
          current:  resources.current_page,
          limit_value: resources.limit_value,
          total_pages: resources.total_pages,
          total_count: resources.total_count,
          next_url: next_page_url(resources),
          prev_url: prev_page_url(resources)
        }
      }
      
      pagination
    end
  end
end

The above error has been fixed.

version >= 1.2.0

@hikonori07 hikonori07 marked this pull request as ready for review March 20, 2023 09:37
@hikonori07 hikonori07 changed the title add require 'kaminari/helpers/helper_methods' in core.rb [WIP]add require 'kaminari/helpers/helper_methods' in core.rb Mar 20, 2023
@hikonori07 hikonori07 changed the title [WIP]add require 'kaminari/helpers/helper_methods' in core.rb [WIP]Add require 'kaminari/helpers/helper_methods' in core.rb Mar 20, 2023
@hikonori07 hikonori07 changed the title [WIP]Add require 'kaminari/helpers/helper_methods' in core.rb Add require 'kaminari/helpers/helper_methods' in core.rb Mar 20, 2023
@hikonori07
Copy link
Contributor Author

@amatsuda @yuki24
Please check back at your convenience.

@amatsuda amatsuda merged commit ffc15f8 into kaminari:master Sep 22, 2023
78 checks passed
@amatsuda
Copy link
Member

amatsuda commented Sep 22, 2023

@hikonori07 Makes sense. Thank you!

@hikonori07 hikonori07 deleted the bugfix/require_url_helper branch September 23, 2023 09:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants