Git Product home page Git Product logo

rqrcode-rails3's Introduction

Render QR codes easily from your Rails 3 application

This gem supports rendering either SVG or PNG, JPEG, and GIF formats.

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.

Installation

Add the following to your Gemfile.

gem 'rqrcode-rails3'

If you want to use the PNG, JPEG or GIF 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'

How to use

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, :level => :l, :unit => 10 }
  format.png  { render :qrcode => request.url }
  format.gif  { render :qrcode => request.url }
  format.jpeg { render :qrcode => request.url }
end

Options:

  • :size – This controls how big the QR Code will be. Smallest size will be chosen by default. Set to maintain consistent size.
  • :level – The error correction level, can be:
    • Level :l 7% of code can be restored
    • Level :m 15% of code can be restored
    • Level :q 25% of code can be restored
    • Level :h 30% of code can be restored (default :h)
  • :offset – Padding around the QR Code (e.g. 10)
  • :unit – How many pixels per module (e.g. 11)
  • :fill – Background color (e.g "ffffff" or :white)
  • :color – Foreground color for the code (e.g. "000000" or :black)

About

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

QR codes are encoded by rqrcode

rqrcode-rails3's People

Contributors

bradleypriest avatar dasch avatar mattconnolly avatar samvincent avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.