Created
March 30, 2012 16:49
-
-
Save iyanski/2252788 to your computer and use it in GitHub Desktop.
Counting results when specifying limit() in mongoid now works
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
1.9.2p290 :022 > Photo.all.count | |
=> 21 | |
1.9.2p290 :023 > Photo.where(orientation: 'portrait').limit(2).count | |
=> 9 | |
1.9.2p290 :024 > Photo.where(orientation: 'portrait').limit(2).count(true) | |
=> 2 | |
1.9.2p290 :025 > |
This page has the answer! < https://stackoverflow.com/questions/16074404/mongoid-limit-does-not-work-in-mongoid-3-1-x
It's basically:
@events.count(limit: 50)
@rgaufman thanks, this save me alot
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Doesn't seem to be :(