Generate 50,000+ line CSV

Paginate. Get one of the more efficient pagination plugins, traverse the pagination yourself and load N rows at a time, while writing the CSV to either disk, or to send_file().

50.000 ActiveRecord objects in memory might not be the best of things.