Help with pdf writer and show controller

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

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 :wink:
(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. [email protected]

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs