For now, I''ve copied the code into the Customer model and required the
imagemagick_wrapper in the model to get this to work. It works fine
but is there no cleaner way?
On Sep 14, 1:20 pm, Ram
<yourstruly.vi...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
wrote:> Hi,
>
> I am using matisimitsu''s barcode-generator for barcodes in PDFs
with
> Prawn and
Prawnto.http://github.com/matsimitsu/barcode-generator/tree/master.
>
> I want to use the barcode method in a model where i generate the PDF
> as a mail attachment, so that I can do this
>
> def with_attachment(pdfFile, customer)
> subject "Voucher"
> recipients customer.email
> from "<x...-bGHiYpY0Uss@public.gmane.org>"
>
> part :content_type => "text/html",
> :body => render_message("with_attachment", :customer
=>
> customer)
>
> attachment :content_disposition => "attachment",
> :body => pdfFile,
> :content_type => "application/pdf",
> :filename => ''voucher.pdf''
> end
>
> Mailer.deliver_with_attachment(customer.generate_pdf_voucher,
> customer)
>
> Where generate_pdf_voucher is a method in the Customer model and
> renders a PDF Document.
>
> But right now, im getting the following error
>
> NoMethodError: undefined method `barcode'' for
#<Customer:0x23fcf94>
>
> How can I get around this problem? barcode_generator extends
> ActionView to add the barcode method.