Created
April 10, 2013 11:22
-
-
Save vparihar01/5353812 to your computer and use it in GitHub Desktop.
the snippet which creates a csv for the given object, we could aslo use streaming to do this same to save memory consumption.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| csv_string = FasterCSV.generate do |csv| | |
| csv << ["Idea Name","Total Votes count","Date Created","Created By"] | |
| csv << [@idea.title, @idea.votes.size,@idea.created_at.strftime("%B %d, %Y"),@idea.created_by] | |
| csv << ["Months","Total Votes count"] | |
| votes_count.each_with_index do |i,j| | |
| csv << [month_names[j] , votes_count[j] ] | |
| end | |
| end | |
| send_data csv_string, | |
| :type => "text/csv; charset=iso-8859-1; header=present", | |
| :disposition => "attachment; filename=Idea.csv" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment