Search code examples
ruby-on-railsrubyqr-code

QR Codes not displaying in emails, Rails


I'm dealing with a legacy Rails website. I am trying to put QR codes in an email (which otherwise works normally on the website), uses QRCode.js.

<% @tires.each do |tire| %>
  <h3>TIRE <%= tire.id %> QR CODE</h3>
  <div class="barcode-main" id="barcode_<%=tire.id%>"></div>
  <script> 
    var qrcode = new QRCode("barcode_<%=tire.id%>", {
    text: "http://jindo.dev.naver.com/collie",
    width: 128,
    height: 128,
    colorDark : "#000000",
    colorLight : "#ffffff",
    correctLevel : QRCode.CorrectLevel.H
    });
  </script>
<% end %> etc

In Gmail inspection the element is:

<div id="m_142369116572343918barcode_49"></div>

In Outlook inspection the element is:

<div id="x_barcode_49"></div>

No class, and the id is altered with gibberish in front of it. Works normally as an attachment and everywhere else.

... I have also now tried the same with RQRCode and Google Chart QR - can get them to show on the website, but not in an email. With RQRCode the elements show up as <u></u> and with Google Chart QR it is a broken image.


Solution

  • I failed with 3 QR gems, and eventually got it with QuickChart (didn't realize Google Charts QR was depreciated).