kaminari-mongoid
kaminari-mongoid copied to clipboard
scope override errore when used with sublcasses
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
Could you provide an example app or a test case that replicates your issue?
in theory you could replicate it easily doing the following
class Parent include Mongoid::Document end
class Child < Parent end
class OtherChild < Parent end
it should throw the exception when loading the file of the child class
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.
i'll try to reproduce it in a separate app. sorry for plain text, i'm replying by mail :(
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
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>