vendredi 20 février 2015

Template missing issue wicked pdf in rails

I am using Wicked_pdf gem to generate the PDF .According to my requirement I need to generate those PDF in background jobs(Resque jobs) and mail them. I defined my PDF generation logic in my library folder. When I am trying to generate the PDF for mailing ,I'm getting missing template issues.


Please find the code snippets for more clarity


The logic in /lib folder



def self.generate_pdf(user,params)
load_pdf_results(user,params)
filename = get_pdf_file_name(@user, @location_name)
PdfReportMailer.new_pdf_report(filename).deliver!
end


Logic in my mailer



def new_pdf_report(filename)
mail(:subject => 'Your pdf', :to => "xyz@abc.com",:body => "pdf generated successfully") do |format|
format.pdf do
attachments[filename] = WickedPdf.new.pdf_from_string(
render_to_string(
:pdf => filename,
:template => "/reports/wpdf_dashboard_pdf_report.pdf.haml",
:layout => "/layouts/application.pdf.haml",
:formats => [:pdf],
:orientation => 'Landscape',
:page_size => 'A4',
:zoom => 0.75,
:javascript_delay => 2000,
:margin => {:top => 10,
:bottom => 10,
:left => 0,
:right => 0},
:header => {:right => '[page] of [topage] ', :margin => {:top => 10,
:bottom => 0,
:left => 10,
:right => 0}}
))
end
end
end


My Resque server throwing following error



Exception
ActionView::MissingTemplate
Error
Missing template reports/wpdf_dashboard_pdf_report1.pdf with {:locale=>[:en], :formats=>[:pdf], :handlers=>[:erb, :builder, :coffee, :haml]}. Searched in: * "/home/sureshtorlapati/Desktop/new/http://ift.tt/1AR0zRO" * "/home/sureshtorlapati/.rvm/gems/ruby-1.9.3-p547@reviewtrackers/gems/letter_opener_web-1.2.2/app/views" * "/home/sureshtorlapati/.rvm/gems/ruby-1.9.3-p547@reviewtrackers/gems/saas-kit-2.5.2/app/views" * "/home/sureshtorlapati/.rvm/gems/ruby-1.9.3-p547@reviewtrackers/gems/devise-2.1.2/app/views"


Anyone please suggest the solution for this issue.


Aucun commentaire:

Enregistrer un commentaire