1
votes

I'm working on PDF creation in my rails application. I found PDFkit didn't necessarily do what I wanted to do, so I figured I'd test out Prawn.

I added it to my controller using this code:

   def show
    @document = Document.find(params[:id])

    respond_to do |format|
      format.html
      format.pdf do
        pdf = Prawn::Document.new(@document)
          send_data pdf.render, filename:"1",
                                type: "application/pdf",
                                disposition: "inline"
        end
     end  
  end

But using this I get a Missing Attribute error. I'm assuming this is because my model is also named Documents and conflicts with the Prawn::Document.new command?

Can I just not have a documents model and use Prawn - or is there something I'm missing here?

1

1 Answers

0
votes

I don't think it's about Document vs Prawn::Document, but I've never seen someone pass an ActiveRecord instance to Prawn::Document.new. I think that expects an options hash, right? And calling render before giving it any content seems suspicious. What is the actual stack trace?