Ruby generates a two-dimensional code using RQRCODE

Reference: https://github.com/whomwah/rqrcode

1. gem’rqrcode’

2. In the helper:

< pre class="hljs ruby"> require ‘base64’ def generate_qr_code string qr_code = RQRCode::QRCode.new string png = qr_code.as_png( resize_gte_to: false, resize_exactly_to: false, fill: ‘white’, color: ‘black’, size: 180, border_modules: 0, module_px_size: 0, file: nil # path to write ).to_s Base 64.encode64 png return “data:image/png;base64,#{Base64.encode64(png)}” end < /span>

3, views page

3. p>

<%= image_tag generate_qr_code('http://baidu.com')%>

WordPress database error: [Table 'yf99682.wp_s6mz6tyggq_comments' doesn't exist]
SELECT SQL_CALC_FOUND_ROWS wp_s6mz6tyggq_comments.comment_ID FROM wp_s6mz6tyggq_comments WHERE ( comment_approved = '1' ) AND comment_post_ID = 3292 ORDER BY wp_s6mz6tyggq_comments.comment_date_gmt ASC, wp_s6mz6tyggq_comments.comment_ID ASC

Leave a Comment

Your email address will not be published.