Skip to content

yesezra/rqrcode-rails3

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

28 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

This gem supports rendering either SVG or PNG format.

SVG, because of it’s vector nature, will scale easily when intended for print. Offering QR endpoints enables others to integrate with your service in possibly interesting ways.

Add the following to your Gemfile.

gem 'rqrcode-rails3'

If you want to use the PNG format, you will have to have ImageMagick installed on your system. You will also want to add the mini_magick gem to your application’s Gemfile.

gem 'mini_magick'

In your controller actions, you could return a QR code that links to the current page like this:

respond_to do |format|
  format.html
  format.svg { render :qrcode => request.url }
  format.png { render :qrcode => request.url }
end

If you wish to render SVG inline (i.e. in your views), you can use the SVG renderer directly:

qr_code = RQRCode::QRCode.new("Hello, world!")
RQRCode::Renderers::SVG::render(qr_code)

This project was inspired by the first chapter in José Valim’s book Crafting Rails Applications

QR codes are encoded by rqrcode

About

Render QR codes with Rails 3

Resources

License

Stars

Watchers

Forks

Packages

 
 
 

Contributors

Languages

  • Ruby 70.9%
  • JavaScript 29.1%