ActionMailer - Attaching a file via Open
In my user_mailer, I'm trying to add an attachment like follows:
tempfile = File.new("#{Rails.root.to_s}/tmp/#{a.attachment_file_name}", "w")
tempfile << open(a.authenticated_url())
tempfile.puts
attachments[a.attachment_file_name] = File.read("#{Rails.root.to_s}/tmp/#{a.attachment_file开发者_StackOverflow社区_name}")
This method: a.authenticated_url()
is getting a valid URL, confirmed that
there's not error message but the file's being attached are corrupt and of the wrong size.
How can I attach a file to AcionMailer thats from a URL?
thanks
精彩评论