Attach CSV String as attachment


#1

I am trying to take a csv string output and send it as a file
attachment, but keep my data is only coming out as gobbly gook. The csv
string is valid going into the mailer action.

Valid CSV

id,name,dealer_code,created_at,quantity,total_quote,shipping_cost
1000012,Testing project,Thu Apr 09 16:31:08 UTC 2009,0,0,0.0
1000013,test,Thu Apr 09 16:35:19 UTC 2009,0,0,0.0

In Action Mailer, I have:

def report(csv, name)
.
.
.
body :name => name
attachment “text/csv; charset=utf-8” do |a|
a.body = csv
a.filename = name
end
end

unfortunately, this gives me:

–mimepart_49de4abf9b848_6d414263a4194
Content-Type: text/csv; name=“New projects”
Content-Transfer-Encoding: Base64
Content-Disposition: attachment; filename=“New projects”

aWQsbmFtZSxkZWFsZXJfY29kZSxjcmVhdGVkX2F0LHF1YW50aXR5LHRvdGFs
X3F1b3RlLHNoaXBwaW5nX2Nvc3QKMTAwMDAxMixUZXN0aW5nIHByb2plY3Qs
LFRodSBBcHIgMDkgMTY6MzE6MDggVVRDIDIwMDksMCwwLDAuMAoxMDAwMDEz
LHRlc3QsLFRodSBBcHIgMDkgMTY6MzU6MTkgVVRDIDIwMDksMCwwLDAuMAo=