0
我對ROR完全陌生。我正在嘗試創建一個簡單的應用程序來創建和發送附件在rails 4.0.0中的電子郵件。用戶應該能夠將圖像嵌入到電子郵件中。電子郵件正在被髮送,圖像也被上傳,但在這個過程中它被破壞,所以收件人無法看到它。 任何人都可以提出解決這個問題的辦法嗎?我的郵件在rails中上傳電子郵件中的圖像4.0.0
代碼:
class UserMailer < ActionMailer::Base
default :from => "[email protected]"
def registration_confirmation(user)
@user = user
attachments['rails.jpg'] = File.read('C:\Ruby\mail\public\images\rails.jpg')
mail(:to => "#{user.name} <#{user.email}>", :subject => "Image attachment")
end
end
嘗試它.. nt wrkn :( – user2536488
你檢查了圖像的路徑是否正確?嘗試將它添加到你的項目並使用'Rails.root'來找到它。例如:'File.read(「#{Rails .root} /public/images/rails.png「)' – NicoSantangelo
L等我知道編輯是否有幫助。 – NicoSantangelo