Pastie now auto-senses if line-wrap is a bad or good idea. Feedback?
## mark a section (Learn more)
# Thanks Jamis class << ActiveRecord::Base def each(limit = 1000) rows = connection.select_all "select id from #{table_name} where id > 0 limit #{limit}" while rows.any? rows.each { |record| yield record } rows = connection.select_all "select id from #{table_name} where id > #{rows.last['id']} limit #{limit}" end self end end # Warming the cache models = Dir["#{RAILS_ROOT}/app/models/**.rb"] models.map! { |dir| File.basename(dir, '.rb').classify.constantize } models.each do |model| model.each { |record| model.get_cache(record['id']) } end
This paste will be private.
From the Design Piracy series on my blog: