Created
March 23, 2013 21:53
-
-
Save anonymous/5229508 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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