has_barcode
has_barcode copied to clipboard
ActionView::Template::Error (data is not valid (extended=false)): on user.barcode_data.html_safe
user modal has: has_barcode :barcode, :outputter => :svg, :type => :code_39, :value => Proc.new { |c| c.tehID }
def tehID self.nid end
(tried :svg and :png[with chunky_png installed] both give same error) And in the view I have:
and when I try to load the page I get the following error: Completed 500 Internal Server Error in 4ms
ActionView::Template::Error (data is not valid (extended=false)): 6: 7:
Any help would be very much appreciated!
Error is caused by special characters like "_".
For code 39
style barcodes only 43 characters are defined. Passing anything other than these 43 characters to be barcodified will result in this error.
This is because has_barcode
internally uses the barby
gem and referring to the source for code_39, the error is triggered from line 97 https://github.com/toretore/barby/blob/master/lib/barby/barcode/code_39.rb#97 , which happens when the valid?
function returns false.
As you can see for a non-extended encoding, the characters passed should be part of ENCODINGS
https://github.com/toretore/barby/blob/master/lib/barby/barcode/code_39.rb#L12-L35 .
So passing lower case characters will throw an error as well.