Commit fb08a533 by Jon Yurek

Rake tasks don't load all instances into memory.

parent aff3396e
...@@ -17,9 +17,10 @@ end ...@@ -17,9 +17,10 @@ end
def for_all_attachments def for_all_attachments
klass = obtain_class klass = obtain_class
names = obtain_attachments names = obtain_attachments
instances = klass.find(:all) ids = klass.connection.select_values("SELECT id FROM #{klass.table_name}")
instances.each do |instance| ids.each do |id|
instance = klass.find(id)
names.each do |name| names.each do |name|
result = if instance.send("#{ name }?") result = if instance.send("#{ name }?")
yield(instance, name) yield(instance, name)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment