Forum: Ruby on Rails Barcode Generating With Label On Canvas by using Barby gem

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
Fe4a0ff2c6fff93b7293f9538b91339b?d=identicon&s=25 saritha chakilala (saritha14)
on 2012-08-07 15:23
********UNDEFINED METHOD REGISTER ERROR IN THE FALLOWING CODE *******
Hi all,

I am trying to generate barcode(including its name as label at the
bottom of barcode image for easy understand with out scanning by barcode
scanner).

For this I am Using barby, chuncky_png, rmagick gems.
I am using the fallowing code to generate label at bottom of image by
using rmagick gem:

gem 'barby'
gem 'chunky_png'
gem 'rmagick'
 require 'rubygems'
 require 'barby'
 require 'barby/outputter/rmagick_outputter'
require 'barby/barcode/code_128'
require 'barby/outputter/prawn_outputter'
require 'pdf/writer'

module Barby
class RmBarcode < ActiveRecord::Base
    register :to_image_with_data
    def to_image_with_data
      #Make canvas  bigger
      canvas = Magick::ImageList.new
      canvas.new_image(full_width , full_height + 10)
      canvas << to_image
      canvas = canvas.flatten_images
      #Make the text
      text = Magick::Draw.new
      text.font_family = 'helvetica'
      text.pointsize = 14
      text.gravity = Magick::SouthGravity
      text.annotate(canvas , 0,0,0,0, barcode.data)
      canvas
    end
  end
end
barcode = Barby::Code128B.new('Barcode Code Here')
barcode.to_image_with_data.write('barcode_2.png')

but I am getting the fallowing error:

undefined method `register' for #<Class:0x4d08ef0>

yy??

any information that is valuable to me.
thanks in advance..........
This topic is locked and can not be replied to.