Rails 4:通过动作邮件让QRCode显示在电子邮件中

我的问题是让我的QRCode显示在通过rails中的动作邮件发送的电子邮件中。 我目前正在使用gem’rqrcode_png’
我已阅读了一些指南并说明了内联附件。 但是,我没有保存在我自己的文件中生成的QRCode。

有没有办法在电子邮件中显示QRCode而无需将其保存在我的数据库中? 此外,我在我的视图页面上尝试了以下代码并且它可以工作,但是当我将其复制到我的动作邮件代码时它不起作用。 它仅显示场地QR码
以下是我的代码,用于显示QRCode。 谢谢!

QR Code for

刘易斯巴克利解决方案的一些编辑

我对代码进行了一些编辑,现在它正在运行。 因为,我使用ruby我必须在变量周围放置才能显示它们。

 " alt="QR code"> 

我不确定您的确切用例,但之前我使用过Google Chart QR代码生成器并且它非常简单(您需要使用u方法对内容进行url编码):

 QR code 

然后将其复制到邮件“视图”中。

 Define @url in the controller. Here's examples to linkto for debugging and the img source for displaying. The above example used url encoding for & and this didn't work for me. Use & for the urls. <%= link_to("https://chart.googleapis.com/chart?chs=545x545&cht=qr&chl=#{@url}&choe=UTF-8","https://chart.googleapis.com/chart?chs=545x545&cht=qr&chl=#{@url}&choe=UTF-8") %> QR code chs=548x547 is the max allowed for size, which you'll need for larger urls.