Skip to content

Instantly share code, notes, and snippets.

@wjessop
Created December 3, 2008 21:36
Show Gist options
  • 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