Topic: drying up export to csv code.
I have a functionality whereby the application can respond_to a complex report report in csv,pdf format.
In cases where the number of rows returned by the query exceeds 1000 lines, the job gets queued to a background process where the user recieves a mail with the report attached, to reduce load on the mongrels.
currently the view logic for csv's are being generated in the models! - which I am refactoring out, but I dont want to keep the same kind of inline ruby code for multiple erb's - html, csv, pdf's etc ...
My question is where do I put this code so this can be leveraged by multiple views - html, csv ... as well as the background process. Im just not sure how to do it in the best possible way. Any help appreciated. Let me know if I need to provide more information.