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

scope override errore when used with sublcasses #11

Open
saten opened this issue Oct 18, 2018 · 6 comments
Open

scope override errore when used with sublcasses #11

saten opened this issue Oct 18, 2018 · 6 comments

Comments

@saten
Copy link

saten commented Oct 18, 2018

Hello,

our app has a class which includes Mongoid::Document and many subclasses.
the following exception is thrown Mongoid::Errors::ScopeOverwrite when kaminari-mongoid attempts to add page scope to each of the subclasses (file mongoid_extensions:12)

mongoid 4.0.2
kaminari master
kaminari-mongoid master

@yuki24
Copy link
Member

yuki24 commented Oct 18, 2018

Could you provide an example app or a test case that replicates your issue?

@saten
Copy link
Author

saten commented Oct 18, 2018 via email

@yuki24
Copy link
Member

yuki24 commented Oct 18, 2018

We have the exact same setup in the test and the build for Mongod 4.0 is green (I just re-ran just in case.) This is why we almost always ask for a test case or an example app that's actually runnable instead of a code snippet that doesn't necessarily replicates the issue.

Also, please use markdown to make your comments more readable. Plain text is very hard to read.

@saten
Copy link
Author

saten commented Oct 18, 2018 via email

@saten
Copy link
Author

saten commented Oct 18, 2018

Hi, could not reproduce the exact behaviour, which I believe is tied to mongoid version.

The following repo is a brand new rails 4.1.x app with mongoid 4.0.2 and kaminari-mongoid

Try creating a Person::Individual record

https://github.com/dSmart-srl/sample_k

@yuki24
Copy link
Member

yuki24 commented Oct 18, 2018

Your example app seems to be working fine after applying the following diff:

diff --git a/Gemfile b/Gemfile
index fa3d1c3..3da07a2 100644
--- a/Gemfile
+++ b/Gemfile
@@ -1,12 +1,17 @@
 source 'https://rubygems.org'

+# Bundle edge Rails instead: gem 'rails', github: 'rails/rails'
+gem 'rails', '4.1.14'

 gem 'mongoid', '~> 4.0.x'
-gem 'kaminari'
+
+git 'https://github.com/kaminari/kaminari' do
+  gem 'kaminari-core'
+end
+
 gem 'kaminari-mongoid'

-# Bundle edge Rails instead: gem 'rails', github: 'rails/rails'
-gem 'rails', '4.1.14'
 # Use sqlite3 as the database for Active Record
 gem 'sqlite3'
 # Use SCSS for stylesheets
Parent::Individual.page(1)
# => #<Mongoid::Criteria
#   selector: {}
#   options:  {:limit=>25, :skip=>0}
#   class:    Parent::Individual
#   embedded: false>

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

No branches or pull requests

2 participants