Ruby on Rails plugin: QRCode

本文介绍了一种在Ruby on Rails项目中使用QR Code的方法。通过一个Rails插件,可以轻松地将JavaScript QR Code生成器集成到项目中。只需简单安装并调用qrcode函数即可在页面上生成指定大小的QR Code。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

I come across this page, a javascript QRCode generator. 1

To simplify the tasks to use it in Rails, I created a plugins QRCode for Ruby on Rails.

Usage

  1. In your rails project, install the plugin by following command:
 ./script/plugin install http://qrcode-rails.googlecode.com/svn/trunk/plugins/qrcode
Add javascript include tag in HTML header:
   <%= javascript_include_tag :defaults %>
Add following funtion to where you want to generate QRCode.
   <%= qrcode('http://www.google.com/', 2) %>
  • The first parameter is URL
  • The second optional parameter is pixel size.
Done!

For details, please check the QRCode project page.

Sample Code
<%= qrcode('http://www.google.com/', 8 ) %>

Sample Screen
qrcode2.png


  1. In case you dont know, QRCode is those mystic code appeared in most japanese media. Snap the QRCode by your cell phone, the code is translated into URL.
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值