Skip to content

Instantly share code, notes, and snippets.

@simsicon
Created March 13, 2014 08:48
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save simsicon/9524574 to your computer and use it in GitHub Desktop.
Save simsicon/9524574 to your computer and use it in GitHub Desktop.
Mongoid doesn't support find_in_batches, this is a work around for it.
per_batch = 10
0.step(User.count, per_batch) do |offset|
puts User.limit(per_batch).skip(offset).map(&:username).inspect
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment