On Jan 16, 1:52 pm, "Michael Libby" <[email protected]> wrote:
> On Fri, Jan 16, 2009 at 12:32 PM, naevity <[email protected]> wrote:
> > <%= barcode 'UPCCODE', :encoding_function => Gbarcode::BARCODE_ISBN %>
>
> Hard-coding it like this works for you, right?
>
> > I need to be able to dynamically input the encoding function like
> > this:
>
> > <%= barcode code.number, :encoding_function => code.type.upctype %>
>
> What are some sample values of code.type.upctype from your database?
>
> -Michael
yes, hardcoding it works. Let's say I want to use an ISBN barcode of
"068816112X"
This works:
<%= barcode '068816112X', :encoding_function => Gbarcode::BARCODE_ISBN
%>
Now, let's say in my types table, I have this:
id: 1
type: book
upctype: GBarcode::BARCODE_ISBN
id: 2
type: dvd
upctype: GBarcode::BARCODE_128
and in my 'items' table (instead of code, works better for the
example) I have this:
id: 1
type_id: 1
name: replay
upcnumber: 068816112X
id: 2
type_id: 2
name: batman
upcnumber: 123456789
I can do this without a problem:
<%= barcode item.upcnumber, :encoding_format => Gbarcode::BARCODE_ISBN
%>
But that would obviously make the next entry of Batman show up wrong,
since it needs to be a BARCODE type of 128.
This is where stuff start's going wrong. I thought I should be able to
enter the below without a problem
<%= barcode item.upcnumber, :encoding_format => item.type.upctype %>
but that's when I get the "in method 'Barcode_Encode', argument 2 of
type 'int' " error.
If you want to take a look at the plugin's code where the
Barcode_Encode method lies, it's here:
http://code.google.com/p/barcode-generator/source/browse/trunk/barcode_generator/lib/barcode_generator.rb
I really appreciate the help, I've wasted an entire day trying to wrap
my head around it. It seems like it should work to me, but I obviously
don't know enough as to why it's not working.
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Ruby
on Rails: Talk" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/rubyonrails-talk?hl=en
-~----------~----~----~----~------~----~------~--~---