Skip to content

Instantly share code, notes, and snippets.

Created March 23, 2013 21:53
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save anonymous/5229508 to your computer and use it in GitHub Desktop.
Save anonymous/5229508 to your computer and use it in GitHub Desktop.
def index
@hospital_bookings = HospitalBooking.scoped
hospital_booking = @hospital_bookings
@user = current_user
if params[:format] == "pdf"
@hospital_bookings = @hospital_bookings.where(:day => Date.today.beginning_of_month..Date.today.end_of_month)
end
respond_to do |format|
format.html
format.pdf do
render :pdf => "#{Date.today.strftime("%B")} Overtime Report",
:header => {:html => {:template => 'layouts/pdf.html.erb'}}
OvertimeMailer.overtime_pdf(@user, hospital_booking).deliver
end
end
end
Template is missing
Missing template overtime_mailer/overtime_pdf with {:locale=>[:en], :formats=>[:html, :text, :js, :css, :ics, :csv, :png, :jpeg, :gif, :bmp, :tiff, :mpeg, :xml, :rss, :atom, :yaml, :multipart_form, :url_encoded_form, :json, :pdf, :zip], :handlers=>[:erb, :builder, :coffee]}. Searched in: * "/home/dj/Desktop/MIUK_Portal/app/views" * "/home/dj/.rvm/gems/ruby-1.9.3-p374/gems/devise-2.2.0/app/views"
class OvertimeMailer < ActionMailer::Base
# DEFAULT_FROM = "miuk-portal@migroup.com"
default :from => DEFAULT_FROM
def overtime_pdf(user, hospital_booking)
@hospital_bookings = hospital_booking
@user = user
attachments["hospital_bookings.pdf"] = WickedPdf.new.pdf_from_string(
render_to_string(
:pdf => "hospital_bookings.pdf",
:header => { :html => { :template => 'hospital_bookings/index.pdf.erb' }},
:layout => "pdf.html")
)
#self.instance_variable_set(:@lookup_context, nil)
mail :subject => "Overtime", :to => user.email
end
end
@unixmonkey
Copy link

Do you have a template for the text and/or html versions of the email?

It is looking for the body of the email to be in app/views/overtime_mailer/overtime_pdf.text.erb

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment