# Help with pdf writer and show controller

**URL:** <https://www.ruby-forum.com/t/help-with-pdf-writer-and-show-controller/125821>\
**Category:** Rails\
**Created:** [January 12, 2008, 1:47pm UTC](https://www.ruby-forum.com/t/help-with-pdf-writer-and-show-controller/125821 "2008-01-12T13:47:00Z")\
**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 12, 2008, 1:47pm UTC](https://www.ruby-forum.com/t/help-with-pdf-writer-and-show-controller/125821/1 "2008-01-12T13:47:00Z")

</div>

This is my show controller for repair\_tickets:

def show  
@repair\_ticket = RepairTicket.find(params[:id])

```
 logger.debug(@rp_parts)

respond_to do |format|
  format.html # show.html.erb
  format.xml { render :xml => @repair_ticket }

  format.pdf do
    send_data RepairTicketDrawer.draw(@repair_ticket), :filename =>

```

‘repair\_tickets/@repair\_ticket.id.pdf’, :type =\> ‘application/pdf’,  
:disposition =\> ‘inline’  
end

and this is my public class:

class RepairTicketDrawer  
def self.draw(repair\_ticket)  
pdf = PDF::Writer.new  
pdf.text “Test”  
pdf.text (repair\_ticket.client\_id)  
pdf.render  
end  
end

This line gices me problems:  
pdf.text (repair\_ticket.client\_id)

I get:  
NoMethodError in Repair ticketsController#show  
undefined method `each’ for 1:Fixnum

---

<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 12, 2008, 11:31pm UTC](https://www.ruby-forum.com/t/help-with-pdf-writer-and-show-controller/125821/2 "2008-01-12T23:31:51Z")

</div>

try pdf.text (repair\_ticket.client\_id.to\_s)

i do this in my classes when generating an report. after that, i did  
not get any more errors 😉  
(I look up attributes in an more generic way, so that i can do  
report\_and\_send(@repair\_ticket, options) and have only the desired  
attributes rendered in an template. there i alwys do the to\_s, since  
once i got an error that sounds like yours with numeric values.

On Jan 12, 1:47 pm, John S. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)
