has_barcode icon indicating copy to clipboard operation
has_barcode copied to clipboard

ActionView::Template::Error (data is not valid (extended=false)): on user.barcode_data.html_safe

Open mclark4386 opened this issue 12 years ago • 2 comments

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: <%= current_user.barcode_data.html_safe %>

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:

8: <%= current_user.barcode_data.html_safe %> 9:
10: 11: <% else %> app/views/users/show.html.erb:8:in `_app_views_users_show_html_erb___1179557980136249438_70109681266960'

Any help would be very much appreciated!

mclark4386 avatar Aug 21 '12 18:08 mclark4386

Error is caused by special characters like "_".

cestrada avatar Apr 07 '15 15:04 cestrada

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.

awinabi avatar Jan 08 '16 05:01 awinabi