views:

285

answers:

2

Hi there, I've used Prawnto quite a bit in a few Rails projects. As I'm trying to integrate it into this project, I'm unable to get it working!

I've installed the plugin, and the files are there:

script/plugin install git://github.com/thorny-sun/prawnto.git

I've added this line to environment.rb in the config block:

config.gem "prawn"

Prawn is installed as a gem and configured:

gem list --local
prawn (0.5.1)
prawn-core (0.5.1)
prawn-format (0.2.1)
prawn-layout (0.2.1)

...among others.

And lastly, I've set up my controller method to handle the PDF:

def print
    @report = Report.find(params[:id])
    prawnto :filename => @report.name + ".pdf", :inline => false
end

The result? A "Template Missing" error. It's looking for "print.erb". I have the view file named "print.prawn.pdf", and no other view files with the same name.

I've spent a couple hours on this, with no luck whatsoever. Any pointers you could provide would be appreciated!

Cheers, Aaron.

A: 

I haven't used Prawnto, but can you specify the template in the prawnto method call?

prawnto :filename => @report.name + ".pdf", :inline => false, :template => "print.prawn.pdf"

I would recommend checking out out Wicked PDF as an alternative if you are still having trouble.

Beerlington
Wicked PDF looks interesting, but I would much rather get this sorted out for this project. I tried using the :template attribute, but no love. :-(
Aaron Vegh
Are you still getting the same error or is it not able to find the template you specify?
Beerlington
I'm getting the same error.
Aaron Vegh
+1  A: 

Here's an update. There appears to be two ways to invoke Prawnto: as I stated above using the "prawnto" method call, and via a respond_to block, like so:

def print
  @report = Report.find(params[:id])
  respond_to do |format|
    format.pdf
  end
end

Now, THIS works. Is this still using Prawnto? Or something else? I'm just throwing my hands up at this point.

Thanks, Aaron.

Aaron Vegh