我正在使用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
这给我以下错误没有这样的文件或目录 – /system/files/7/original/image.png?1254497688与堆栈跟踪说它是对File.read的调用.当我访问show.html.erb页面,并点击图像的链接,这是像http:// localhost:3000 / system / files / 7 / original / image.png?1254497688,图像显示精细.
如何解决这个问题?