trying to pass a variable as the encoding format

19 views
Skip to first unread message

roadtrippr

unread,
Jan 16, 2009, 11:46:05 AM1/16/09
to barcode-generator
I love the plugin, but I'm having trouble passing the encoding format.
Currently I'm storing the encoding format in the database like this:
Gbarcode::BARCODE_128

When calling the plugin in my View, I have this:
<%= barcode code.number, :encoding_format => code.types.upctype %>

I get this error message:
in method 'Barcode_Encode', argument 2 of type 'int'


This happens with any type of option I try to pass, :width, :height,
nothing seems to work. I've also tried passing the entire
":encoding_format => Gbarcode::BARCODE_128" as the variable like this:

<%= barcode code.number, code.type.upctype %>

but that gives me the exact same error:
in method 'Barcode_Encode', argument 2 of type 'int'

Finally, I tried storing the entire expression in the database and
called it like this:
<%= barcode code.number %>

and I get this error message:
wrong number of arguments (1 for 2)


I'm able to just call the barcode number from the database without any
troubles, but I'm not able to dynamically pull the encoding options
from the database. Any ideas?

Anuj Luthra

unread,
Jan 17, 2009, 2:53:51 AM1/17/09
to barcode-...@googlegroups.com
Hi Jonathan,

I'm overseas on a vacation, will get back home in about 3 weeks and have a look at it. In the mean time, why don't you have a look at source.... its not big ... about 3 files :)

At first looks, it seems that the way you are passing in Gbarcode constants is wrong. Storing the constant in db and then fetching it will give you a string like 'Gbarcode::BARCODE_128' which will cause mismatch of string and int; just like the error message hints at.

have fun, will get in touch soon.

regards,
Anuj.

2009/1/16 roadtrippr <jonathan...@gmail.com>



--
Anuj

roadtrippr

unread,
Jan 17, 2009, 5:10:02 PM1/17/09
to barcode-generator
Hi Anuj,

Thanks for the quick reply.

You were right, I was able to work it out with the help of the people
on the Ruby on Rails group and the use of the console. It was a
mismatch of the string 'Gbarcode::BARCODE_128' when it was looking for
an INT.

To get around it, I just got the int value of each barcode type using
the console and stored it in the database. So instead of calling the
string, it calls the int and works great.

Thanks again!

Jonathan



On Jan 17, 2:53 am, Anuj Luthra <anuj.lut...@gmail.com> wrote:
> Hi Jonathan,
>
> I'm overseas on a vacation, will get back home in about 3 weeks and have a
> look at it. In the mean time, why don't you have a look at source.... its
> not big ... about 3 files :)
>
> At first looks, it seems that the way you are passing in Gbarcode constants
> is wrong. Storing the constant in db and then fetching it will give you a
> string like 'Gbarcode::BARCODE_128' which will cause mismatch of string and
> int; just like the error message hints at.
>
> have fun, will get in touch soon.
>
> regards,
> Anuj.
>
> 2009/1/16 roadtrippr <jonathan.mulc...@gmail.com>

Anuj Luthra

unread,
Jan 18, 2009, 11:14:42 PM1/18/09
to barcode-...@googlegroups.com
glad to be of any help at all Jonathan.

have fun :)

btw, i'd love to know, in what scenario/application are you using the barcode plugin?

2009/1/18 roadtrippr <jonathan...@gmail.com>



--
Anuj

roadtrippr

unread,
Jan 25, 2009, 9:12:11 PM1/25/09
to barcode-generator
Hi Anuj,

I'm planning on building a web-based application for smartphones...
we'll see how far I get :)

Thanks again,

Jon

On Jan 18, 11:14 pm, Anuj Luthra <anuj.lut...@gmail.com> wrote:
> glad to be of any help at all Jonathan.
>
> have fun :)
>
> btw, i'd love to know, in what scenario/application are you using the
> barcode plugin?
>
> 2009/1/18 roadtrippr <jonathan.mulc...@gmail.com>

Anuj Luthra

unread,
Jan 25, 2009, 11:44:28 PM1/25/09
to barcode-...@googlegroups.com
good luck :)

2009/1/26 roadtrippr <jonathan...@gmail.com>



--
Anuj

Jonathan

unread,
Feb 20, 2009, 1:27:51 PM2/20/09
to barcode-generator
Hi Anuj,

I've got a followup question on the plug, do you know off the top of
your head how to alter the plugin to rotate the barcodes 90 degrees
using imagemagick? I'm doing some research now, and it looks like I
need to pass a -rotate 90 into the convert function, but I wanted your
opinion. I havn't actually tested it yet though.

Thanks
Jonathan

On Jan 25, 11:44 pm, Anuj Luthra <anuj.lut...@gmail.com> wrote:
> good luck :)
>
> 2009/1/26 roadtrippr <jonathan.mulc...@gmail.com>
> Anuj- Hide quoted text -
>
> - Show quoted text -
Reply all
Reply to author
Forward
0 new messages