On Jan 16, 1:18 pm, “Michael L.” email@example.com wrote:
plugin rather than the underlying value referred to by the constant
Thank’s for the response Michael and Robby, here’s my response before
I saw what Michael wrote:
This smells funny… so I wanted to ask for more information. How is
the ruby code going to be added into the database? Would users be
inputting ruby code somehow?
Well, it’s a workaround to another problem I’m running into. I’m
trying to use the barcode-generator plugin (http://code.google.com/p/
barcode-generator/), which is based on the gbarcode gem.
In my database I have two tables, one for the numbers, and one for the
types of codes
to use the plugin, you call <%= barcode ‘UPCCODE’ %> in the view, and
it generates the code to create and display the PNG. My problem is
that I’m trying to add the :encoding_function option to the code,
which would look something like this:
<%= barcode ‘UPCCODE’, :encoding_function => Gbarcode::BARCODE_ISBN %>
I need to be able to dynamically input the encoding function like
<%= barcode code.number, :encoding_function => code.type.upctype %>
but this pops up errors.
I’ve tried every combination of trying to pass that value, and it
always fails. So, as a last resort, I wrote code to just write the
whole line to the database for each UPCnumber, i.e.:
<%= barcode ‘TEST1234’, :encoding_function => Gbarcode::BARCODE_39 %>
<%= barcode ‘234567890987’, :encoding_function =>
<%= barcode ‘U567890298322E’, :encoding_function =>
But, as I said above, when I try to pull this code, and run it to
generate and display the barcode, it fails.
code: <%= barcode card.cardnumber, :encoding_format =>
result: in method ‘Barcode_Encode’, argument 2 of type ‘int’
code: <%= barcode card.cardnumber, card.rewards.upctype %>
code.type.upctype: :encoding_format => Gbarcode::BARCODE_ISBN
result: index 94105 out of string