Skip to content

Instantly share code, notes, and snippets.

@wjessop
Created December 3, 2008 21:36
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 wjessop/31709 to your computer and use it in GitHub Desktop.
Save wjessop/31709 to your computer and use it in GitHub Desktop.
class << ActiveRecord::Base
def each(limit = 1000)
rows = find(:all, :conditions => ["id > ?", 0], :limit => limit)
until rows.blank?
rows.each { |record| yield record }
rows = find(:all, :conditions => ["id > ?", rows.last.id], :limit => limit)
end
self
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment