Reputation: 925
I'm using rails 4.2 and use paperclip to handle my image uploads. I am trying to attach the image from my model to an email. Per the Rails guides I have my mailer like so
def sub_conversion_email(user, blend)
@user = user
@blend = blend
attachments.inline[@blend.image.original_filename] = File.read(@blend.image.url(:medium))
mail(to: @user.email, subject: "A subject...")
end
Then in my mailer view I have
<%= image_tag attachments[@blend.image.original_filename].url %>
For some reason I'm getting the error
No such file or directory @ rb_sysopen - /system/blends/images/000/000/015/medium/filename.jpg
What am I doing wrong? Thanks.
Upvotes: 1
Views: 972
Reputation: 925
So thanks to Taryn East pointing out that I needed to use path
instead of url
in the File.read()
, it is working. The only thing is that in the mailer preview, it won't show the image. When I inspect the image, its src is cid:........................mycomputer.mail
. When I actually send the email, it works just fine. Anyone know how to get it to show in the mailer preview?
Upvotes: 1