0

This questions is somewhat related to this question Prawn + Prawnto Issue. I've noticed that if something is really hard to do in rails, you're probably doing it wrong.

I have prawnto and prawn installed, and if I go to http://localhost:3000/holders/1.pdf I get exactly the PDF I want except for I have a variable count that is manually set in the pdf currently that I need to pass to each pdf as it is created.

My approach was to create a generate action that was supposed to generate the pdf, but I can't seem to get that to work. Prawnto's documentation is down.

What is the easiest way to do this using prawn + prawnto? Is my generate action the wrong approach?

Community
  • 1
  • 1
Noah Clark
  • 8,101
  • 14
  • 74
  • 116

1 Answers1

1

Doesn't using a plain @ variable work? I do this all the time.

# controller
def show
  @count = 55
  respond_to do |format|
    format.pdf { prawnto }
  end
end

# show.pdf.prawn
pdf.text @count
Unixmonkey
  • 18,485
  • 7
  • 55
  • 78
  • Yeah, that's what I did. What I was trying to do is have a generate.pdf.prawn and then have the show view pass the count variable to the generate controller and have that generate the pdf. I was over complicating it. – Noah Clark Jul 19 '12 at 14:31