Created
December 7, 2011 16:43
-
-
Save jonpaul/1443528 to your computer and use it in GitHub Desktop.
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
def download | |
@email = User.emails.concat(Organization.emails).compact! | |
outfile = "members_" + Time.now.strftime("%D") + ".csv" | |
unless @email.blank? | |
data = CSV.generate do |csv| | |
csv << ['Email'] | |
@email.each do |e| | |
csv << [e] | |
end | |
end | |
end | |
send_data data, :type => 'text/csv; charset=iso-8859-1; header=present', :disposition => "attachment; filename=#{outfile}" | |
flash.now[:notice] = "Export Complete!" | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Send a CSV without writing a file, gogogadget send_data!