There are multiple barcode generator gems available, i decided on 'barby'
First I adding barby to the Gemfile file and using bundler to download and install said gem
Then I had to add the needed 'require' lines to controllers and views using barby. Code-128 is the type of barcode I needed to use.

require 'barby'
require 'barby/barcode/code_128'

Finally using the following lines of code I generated the barcode as a PNG and saved it into a file:

@barcode ="1234")
outputter =
outputter.xdim = 2'barcode.png','wb') {|f| f.write outputter.to_png }



Subscribe to Barcodes