-
Type: Task
-
Resolution: Done
-
Affects Version/s: None
-
Component/s: None
Hi!
We found a problem with the mongoid gem. Limit and offset options for scopes on embedded objects are breaking if the result would be empty. See the following piece of code:
https://gist.github.com/3891253
Calling Something.test leads to the following output:
test pagination with page 1 and limit 6 ["test object 0", "test object 1", "test object 2", "test object 3", "test object 4", "test object 5"] test pagination with page 2 and limit 6 ["test object 6", "test object 7", "test object 8", "test object 9"] test pagination with page 3 and limit 6 [] test embedded pagination with page 1 and limit 6 ["embedded 0-0", "embedded 0-1", "embedded 0-2", "embedded 0-3", "embedded 0-4", "embedded 0-5"] test embedded pagination with page 2 and limit 6 ["embedded 0-6", "embedded 0-7", "embedded 0-8", "embedded 0-9"] test embedded pagination with page 3 and limit 6 NoMethodError - undefined method `each' for nil:NilClass: /<path_to_gems>/gems/mongoid-3.0.6/lib/mongoid/contextual/memory.rb:120:in `each' ....