Skip to content

Instantly share code, notes, and snippets.

@piotrze
Last active August 24, 2016 13:55
Show Gist options
  • Save piotrze/375953e58b9068ecfccdc7ac67803bf2 to your computer and use it in GitHub Desktop.
Save piotrze/375953e58b9068ecfccdc7ac67803bf2 to your computer and use it in GitHub Desktop.
Extract method with block
def generate
prefetch_volunteers do |volunteer|
csv << VolunteerPresenter.new(volunteer).to_csv
end
end
private
def prefetch_volunteers
@volunteers.includes(
[:user, { taggings: :tag }]
).find_each(batch_size: 1000, &Proc.new)
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment