# Help with PDF Writer and link\_to

**URL:** <https://www.ruby-forum.com/t/help-with-pdf-writer-and-link-to/127091>\
**Category:** Rails\
**Created:** [January 24, 2008, 10:51pm UTC](https://www.ruby-forum.com/t/help-with-pdf-writer-and-link-to/127091 "2008-01-24T22:51:10Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![captaffy](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/f04885/32.png) [@captaffy](https://www.ruby-forum.com/u/captaffy)\
**Post date:** [January 24, 2008, 10:51pm UTC](https://www.ruby-forum.com/t/help-with-pdf-writer-and-link-to/127091/1 "2008-01-24T22:51:10Z")

</div>

I have this code in the controller:

def search2  
@repair\_tickets =  
RepairTicket.search(params[:search][:client\_id],params[:search][:product\_id],params[:search][:status\_id],params[:search][:pos\_breakdown\_id],params[:search][:breakdown\_id],params[:search][:query])  
respond\_to do |format|  
format.html  
format.pdf do  
send\_data SearchRepairTicketDrawer.draw(@repair\_tickets),  
:filename =\> ‘repair\_tickets/search2/@repair\_tickets.pdf’, :type =\>  
‘application/pdf’, :disposition =\> ‘inline’  
end  
end  
end

And I have this code in search2.html.erb:

…

\<%= link\_to 'PDF Format', formatted\_repair\_ticket\_path(@repair\_tickets, :pdf) %\>

I want this last link to link to the pdf wich I create in search2  
method. If I quit the format.html line, it generates the pdf I want, but  
i want a link to do it. Help!

---

<div class="post-metadata">

**Author:** ![captaffy](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/f04885/32.png) [@captaffy](https://www.ruby-forum.com/u/captaffy)\
**Post date:** [January 24, 2008, 10:59pm UTC](https://www.ruby-forum.com/t/help-with-pdf-writer-and-link-to/127091/2 "2008-01-24T22:59:49Z")

</div>

I have tried this link\_to:

\<%= link\_to 'PDF Format', :controller =\> "repair\_tickets", :action =\> "search2", :format =\> "pdf" %\>

Then I get that search2.pdf doesn’t exist, but it i quit the line  
format.html, I get the pdf (but in the line of the explorer I don’t get  
.pdf)
