我正在使用 Paperclip 允许用户附加内容,然后我正在发送电子邮件并希望将文件附加到电子邮件中。我正在尝试读取文件并将其添加为附件,如下所示:
# models/touchpoint_mailer.rb
class TouchpointMailer < ActionMailer::Base
def notification_email(touchpoint)
recipients "me@myemail.com"
from "Touchpoint Customer Portal <portal@touchpointclients.com>"
content_type "multipart/alternative"
subject "New Touchpoint Request"
sent_on Time.now
body :touchpoint => touchpoint
# Add any attachments the user has included
touchpoint.assets.each do |asset|
attachment :content_type => asset.file_content_type,
:body => File.read(asset.url)
end
end
end
这给了我以下No such file or directory - /system/files/7/original/image.png?1254497688
堆栈跟踪错误,说它是对File.read
. 当我访问该show.html.erb
页面时,单击图像的链接,类似于http://localhost:3000/system/files/7/original/image.png?1254497688
,图像显示正常。
我该如何解决这个问题?