ruby-on-railsrubypdf-generationprawnprawnto

undefined local variable or method `pdf' for


I'm trying to generate a pdf file in rails with Prawn! as explained here

Exactly the same! but I've Got this Error :

undefined local variable or method `pdf' for #<#<Class:0x005619ea6fecd0>:0x005619e9f54660>

for this line!

pdf.text "Hello World!"

It seems It doesn't understand the 'pdf.' Could you possibly help me ?? Thanks in advance :)


Solution

  • I myself Found the answer Let's review Together. this is my controller

    def show
      @resume = current_user.resume
    end
    

    this is my view (button):

    <%= link_to t(:ExporttoPDF) , resume_path( :format => "pdf"),class:"btn btn-danger btn-lg"%>
    

    and i added all of these gems to my gem file!

     gem 'prawn_rails'
     gem 'prawn'
     gem 'prawn-table', '~> 0.1.0'
     gem 'prawnto'
    

    and this is my show.pdf.prawn file in resume view!

    pdf.text "Hello World!"
    

    and it dose work like a charm! Note: I think my controller had some problem :)