【发布时间】:2017-12-30 03:08:59
【问题描述】:
我目前能够使用 ActionMailer 生成 QR 码,但我无法在电子邮件中实际发送该 QR 码。元素正在正确发送,但图像已损坏,仅显示 alt。我可以在我的 ActionMailer 预览中看到 QR 码,但由于某种原因,在发送/接收电子邮件时它没有通过。
我正在使用 barby 在我的 CompanyLeadRsvpTicketModel 中创建 QR 码。
这是我模型中的代码:
def generate_qr(text)
require 'barby'
require 'barby/barcode'
require 'barby/barcode/qr_code'
require 'barby/outputter/png_outputter'
barcode = Barby::QrCode.new(text, level: :q, size: 5)
base64_output = Base64.encode64(barcode.to_png({ xdim: 5 }))
return "data:image/png;base64,#{base64_output}"
end
这是我认为的代码:
<h1>Hi <%= @company_lead_rsvp_ticket.company_lead[0].first_name%>! Here is your RSVP ticket for the <%=@event.title%>!</h1><h2>Please bring this ticket to check in for the event.</h2><%=image_tag("#{@company_lead_rsvp_ticket.generate_qr(@company_lead_rsvp_ticket.otp_secret_key)}", :alt => "qrcode")%><p><%= @company_lead_rsvp_ticket.confirmation %></p>
【问题讨论】:
标签: ruby-on-rails ruby qr-code actionmailer