Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9115093
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T04:20:56+00:00 2026-06-17T04:20:56+00:00

Hi i have create a PDF conversion in my rails application using Prawn and

  • 0

Hi i have create a PDF conversion in my rails application using Prawn and it working fine.
Now i am sending that PDf in an email attachment. Now problem is that i can send PDF attachment if i do not use any helper method, but when i use my format_currency method in PDf file it gives error on instance_eval method. here is my code sample:
format currency code:

module ApplicationHelper

def format_currency(amt)
    unit = 'INR'
    country = current_company.country
    if !country.blank? && !country.currency_unicode.blank?
      unit = country.currency_unicode.to_s
    elsif !country.blank? 
      unit = country.currency_code.to_s
    end
    number_to_currency(amt, :unit => unit+" ", :precision=> 2)   
  end 
end 

My controller code :

pdf.instance_eval do
      @company = current_company
      @invoice = invoice
      @invoice_line_items = invoice_line_items
      @receipt_vouchers = receipt_vouchers
      eval(template) #this evaluates the template with your variables
    end

the error message i got :

undefined method `format_currency' for #<Prawn::Document:0x7f89601c2b68>

with this code i can send attachment successfuly if i don’t use helper method but i need to use that method.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-17T04:20:57+00:00Added an answer on June 17, 2026 at 4:20 am

    I have fixed this issue in a different manner, i have created a new currency_code method in my company model and called that in my format_currency helper method and it is working for me fine:
    Here is what i have done :

    def currency_code
      unit = 'INR'
      if !country.blank? && !country.currency_unicode.blank?
          unit = country.currency_unicode.to_s
      elsif !country.blank? 
          unit = country.currency_code.to_s
      end
       unit
    end
    

    and used it in my format_currency helper :

    def format_currency(amt)
        unit = current_company.currency_code
        number_to_currency(amt, :unit => unit+" ", :precision=> 2)   
      end 
    

    and in my controller i have added a variable for currency and used it in my pdf file:

     pdf.instance_eval do
          @company = current_company
          @invoice = invoice
          @invoice_line_items = invoice_line_items
          @receipt_vouchers = receipt_vouchers
          @currency = current_company.currency_code # new added variable for currency
          eval(template) #this evaluates the template with your variables
        end
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm using XSL-FO to create PDF's. Now I have a label that I want
I have created an application server side that will create a pdf of a
I am using PDFsharp to create PDF files in my C# application. It's working
I have written an apex class that will create a PDF quote and attach
I have some SVG files that I'd like to create a PDF with. For
I have used following code to create a simple PDF file. It executes fine
I have a directory with PDF files that I need to create an index
I have a webapp that export reports in PDF. Everything is fine when the
I have an Excel template that I use to create PDF specification sheets for
I have a html to pdf conversion tool which resides on our server that

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.