# Using Prawn in Rails 2.3.5

**URL:** <https://www.ruby-forum.com/t/using-prawn-in-rails-2-3-5/186078>\
**Category:** Rails\
**Created:** [March 31, 2010, 10:00am UTC](https://www.ruby-forum.com/t/using-prawn-in-rails-2-3-5/186078 "2010-03-31T10:00:58Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![yasser](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/y/5f9b8f/32.png) [@yasser](https://www.ruby-forum.com/u/yasser)\
**Post date:** [March 31, 2010, 10:00am UTC](https://www.ruby-forum.com/t/using-prawn-in-rails-2-3-5/186078/1 "2010-03-31T10:00:58Z")

</div>

Hi

I’m a big fan of Railscasts as I’ve been using them to further my  
learning in Ruby on Rails. I’m a student at Carnegie Mellon University  
and I’m having a problem with a gem that I have to use for my class  
project. I had followed a tutorial for using Prawn from RailsCasts,  
and I followed each and every step from setup to testing it as shown  
in the video.

However, when I implemented it, I first got an error ‘unitialized  
constant Mime::PDF’. I fixed it by adding ‘Mime::Type.register\_alias  
"application/pdf’ in /config/initializers/mime\_types.rb of my project.  
FYI, my current project started off as a scaffold. I also created a  
sample .pdf.prawn file with “pdf.text ‘Sample PDF output’”. Now I get  
the following error:

All my routes are pluralized and I’m testing this out on ‘index’.  
Following is the scaffolded code with the extra line that is supposed  
to render the pdf:

def index  
@administrators = Administrator.all

```
respond_to do |format|
  format.html # index.html.erb
  format.xml {render :xml => @administrators }
  format.pdf {render :layout => false}
end

```

end

///////  
As for the error that takes place when I do  
[http://127.0.0.1:3001/administrator.pdf:](http://127.0.0.1:3001/administrator.pdf:)  
“Routing Error  
No route matches “/administrator” with {:method=\>:get}”

when I do [http://127.0.0.1:3001/administrators.pdf](http://127.0.0.1:3001/administrators.pdf), I get the  
following:  
“Template is missing  
Missing template administrators/index.erb in view path app/views”  
//////  
Just some info: I have Rails 2.3.5, and doing my development on Aptana  
RadRails as it has worked for me before. This is all taking place in  
Windows XP.

I will appreciate any help to resolve this. Even a step by step  
tutorial that starts afresh.

---

<div class="post-metadata">

**Author:** ![yasser](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/y/5f9b8f/32.png) [@yasser](https://www.ruby-forum.com/u/yasser)\
**Post date:** [March 31, 2010, 7:51pm UTC](https://www.ruby-forum.com/t/using-prawn-in-rails-2-3-5/186078/2 "2010-03-31T19:51:44Z")

</div>

Ok, I had a lot of issues with this too, so I will just put all the  
steps I used to get it to work.

#SETUP  
#though I’m sure bundler would be better for this  
Installed Prawn gem  
config.gem ‘prawn’, :version =\> ‘0.6.3’

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

#Routes  
map.with\_options(:controller =\> ‘admin/reports’) do |m|  
m.admin\_marketing\_report ‘admin/marketing’, :controller =\>  
‘admin/reports’, :action =\> ‘marketing’  
end

#Controller  
class Admin::ReportsController \< AdminController  
def marketing  
respond\_to do |format|  
format.pdf do  
@advertisements = Advertisement.all  
end  
end  
end  
end

#VIEW  
/admin/reports/marketing.prf.prawn  
pdf.text “Marketing Report”, :size =\> 18, :style =\> :bold

Hopefully this will help you out.

~Jeremy
