Skip to content
Discussion options

You must be logged in to vote

The likely issue is that Pagy::OffsetPaginator defines paginate as a module function.

In that shape, prepending into the module itself changes the instance method side, but the method Pagy calls is the module's singleton method. Try prepending into the singleton class instead:

require "pagy/toolbox/paginators/offset"

module PagyWithI18nKey
  def paginate(collection, options)
    model_name =
      if collection.respond_to?(:model_name)
        collection.model_name
      elsif collection.respond_to?(:klass)
        collection.klass.model_name
      elsif collection.is_a?(Array) && collection.first
        collection.first.model_name
      end

    i18n_key = options.delete(:i18n_key)
    i…

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@pontflorian
Comment options

Answer selected by pontflorian
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants