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

undefined local variable or method `default_per_page' for Class Did you mean? default_scope #9

Closed
deniciocode opened this issue Dec 20, 2017 · 12 comments
Labels

Comments

@deniciocode
Copy link

deniciocode commented Dec 20, 2017

After I updated kaminari I received an error for Mongoid. When I use the kaminari-mongoid gem I have the following issue.

undefined local variable or method 'default_per_page' for Profile:Class Did you mean? default_scope

screen shot 2017-12-20 at 14 35 01

I updated the version from 0.16.3 to 1.1.1

@yuki24
Copy link
Member

yuki24 commented Dec 20, 2017

Interesting. It's the most basic feature of Kaminari and I have no idea how this bug slipped in. Would you mind creating an example app that replicates your issue?

Thanks for reporting!

@deniciocode
Copy link
Author

Hey @yuki24,

I created a new rails project and kaminari works here for mongoid.

I have to dig into my Project where I updated the version of kaminari from 0.16.3 to 1.1.1. Maybe I did not configured it right or something is not loaded inside rails.

If I find something when I will show it.

Thank you for your quick response.

@deniciocode
Copy link
Author

deniciocode commented Dec 21, 2017

Do I need a specific version for mongoid here? Iam using mongoid version 4.0.2

@noelrappin
Copy link

noelrappin commented Dec 21, 2017

I am having the same error on Mongoid 4.0.2. I am also upgrading from 0.16.3 to 1.1.1.

Our investigation has shown that Kaminari::ConfigurationMethods is mixed in to our classes per the ancestors method, but the method missing error still happens, when we go into a Pry console and run Foo.send(:include, Kaminari::ConfigurationMethods), then the class method works, although the ancestor list has not changed as far as we can tell.

We are on Rails 4.2.10.

@noelrappin
Copy link

noelrappin commented Dec 21, 2017

kaminari_sample.zip

Here's a sample app that exhibits the behavior. It is a stock Rails 4.2.x that has added Mongoid and Kaminari-Mongoid to the gem file. There is one model, Foo. From my pry session:

> Foo.default_per_page
NoMethodError: undefined method `default_per_page' for Foo:Class

> Foo.ancestors
=> [Foo, Mongoid::Document, Kaminari::Mongoid::MongoidExtension::Document, Kaminari::ConfigurationMethods...]

> Foo.send(:include, Kaminari::ConfigurationMethods)
=> Foo
irb(main):004:0> Foo.default_per_page
=> 25

> Foo.ancestors
=> [Foo, Mongoid::Document, Kaminari::Mongoid::MongoidExtension::Document, Kaminari::ConfigurationMethods...]

The ancestor list doesn't change. Is this some kind of load order issue?

@yuki24
Copy link
Member

yuki24 commented Dec 21, 2017

I'm not sure yet but this commit may be it: kaminari/kaminari@4536cc2

@yuki24
Copy link
Member

yuki24 commented Dec 21, 2017

confirmed kaminari/kaminari@4536cc2 broke the integration with mongoid 4.0.

@yuki24 yuki24 added the bug label Dec 21, 2017
yuki24 added a commit to kaminari/kaminari that referenced this issue Dec 21, 2017
This reverts commit 4536cc2.

This has introduced a loading issue in kaminari-mongoid:
  kaminari/kaminari-mongoid#9
@yuki24
Copy link
Member

yuki24 commented Dec 22, 2017

This issue has been fixed by kaminari/kaminari@d38c684. We'll cut a new release in a few weeks. Thanks!

@yuki24 yuki24 closed this as completed Dec 22, 2017
@deniciocode deniciocode changed the title undefined local variable or method `default_per_page' for Profile:Class Did you mean? default_scope undefined local variable or method `default_per_page' for Class Did you mean? default_scope Dec 22, 2017
@rdunlop
Copy link

rdunlop commented Apr 2, 2018

Hi @yuki24 did a new release get cut?

@yuki24
Copy link
Member

yuki24 commented Apr 2, 2018

@rdunlop No not yet.

@joe1chen
Copy link

+1 Just ran into this bug. Any chance you can cut a new release?

@nchatu
Copy link

nchatu commented Nov 22, 2019

+1 ran into this bug.

mongoid (4.0.2)
kaminari-mongoid (1.0.1)
rails (4.1.1)
ruby (2.2.0)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

6 participants