I don't think this can be the last line. self.prefetch should return an array of instances, so instances.each block needs to be the last line or it needs to be stored as a variable and returned.