0
在Rails應用程序中,我試圖在電子郵件中嵌入(嵌入)圖像(徽標)。Rails在電子郵件中嵌入圖像
這是invoice.mailer.rb:
class InvoiceMailer < ActionMailer::Base
def invoice_email(invoice)
@invoice = invoice
@recipients = @invoice.workorder.client.contacts.where(:receiveinvoices => true)
tomail = @recipients.collect(&:email).join(",")
frommail = @invoice.tenant.from_email
copymail = @invoice.tenant.copy_email
attachments.inline['AME_Logo.gif'] = File.read(Rails.root.join('app/assets/images/AME_Logo.gif'))
mail(
:to => tomail,
:bcc => copymail,
:from => frommail,
:subject => "New Invoice from " + @invoice.tenant.name
)
end
end
這是_invoice_email.html.erb:
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<style type="text/css" media="screen">
</style>
</head>
<body style="margin-left: auto; margin-right: auto; width: 700px">
<div class="invoice">
<div class="inv_header" style="margin-left:10px; margin-right: auto; width: 650px">
<h4>Invoice</h4>
<%= image_tag attachments['AME_Logo.gif'].url -%>
</div>
我從IMAGE_TAG代碼行收到此錯誤:
undefined local variable or method `attachments' for #<#<Class:0x007f8a49ce7b08>:0x007f8a4e352110>
感謝您的幫助!
我已經試過'<%= IMAGE_TAG( 「/images/AME_Logo.gif」,:class =>'pull-right padding-right')%>' - 圖像是附件,但不是內聯。 – Reddirt 2014-12-01 21:11:01