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

Must use page_method_name for all Kaminari pagination #2712

Merged
merged 1 commit into from
May 2, 2019

Conversation

carsonreinke
Copy link
Contributor

Fixes #2711

@mshibuya
Copy link
Member

Spec is failing, can you make it pass?

@carsonreinke
Copy link
Contributor Author

Yeah, Kaminari defines the pagination method statically like this:

    # items at the specified "page"
    class_eval <<-RUBY, __FILE__, __LINE__ + 1
      def #{Kaminari.config.page_method_name}(num = 1)
        offset(limit_value * ((num = num.to_i - 1) < 0 ? 0 : num))
      end
    RUBY

So really, tests were wrong before. Their classes would have to be forcefully reloaded to change the pagination method on the fly.

@carsonreinke
Copy link
Contributor Author

Without having a fork of some sort, it is not really possible to dynamically change the Kaminari page method. The ActiveRecord portion is even more complicated to try and reload.

I see 3 tests that are incorrectly using this approach.

Any advice, thoughts, wisdom to get something setup would be appreciated.

@mshibuya mshibuya added this to the 2.0.0 milestone May 2, 2019
mshibuya added a commit that referenced this pull request May 2, 2019
@mshibuya mshibuya merged commit 92735c8 into railsadminteam:master May 2, 2019
@mshibuya
Copy link
Member

mshibuya commented May 2, 2019

Added a spec in 73ce325, thanks.

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.

undefined method `page' for []:Kaminari::PaginatableArray
2 participants