Add image from URL as an attachment in Rails 3
actionmailer, email, ruby-on-rails, ruby-on-rails-3
Solution
you need to
require 'open-uri'
and then do
attachments["filename"] = open(url-to-image).read
Problem
I know you can add an image as an attachment to an email in Rails 3 with ``` def email_image(email) attachments["img"] = File.read('/path to image') mail(:to => email) end ``` but is there a way to attach an image from a url and not one that is saved locally? I would like to attach an image that is saved on S3 with paperclip. Is there an easy way to do this or do I need to download the image first?