Skip to content

Instantly share code, notes, and snippets.

@angelacode
Created December 18, 2010 17:34
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 angelacode/746686 to your computer and use it in GitHub Desktop.
Save angelacode/746686 to your computer and use it in GitHub Desktop.
def new
11 @contact_fax = ContactFax.new
12 @contact_fax.contact_id = params[:contact]
13 @contact_fax.fax_id = params[:fax]
14
15 @contact = Contact.find(params[:contact])
16 @company = Company.find(@contact.company_id)
17
18 @fax = Fax.find(@contact_fax.fax_id)
19
20 @contact_fax.subject = @fax.substituted_subject(@contact, @contact.colleagues)
21 @contact_fax.date_sent = Date.today
22 #@contact_fax.date_created = Date.today
23 @contact_fax.body = @fax.substituted_message(@contact, @contact.colleagues)
24 @contact_fax.status = "sent"
25 end
26
27 def create
28 @contact_fax = ContactFax.new(params[:contact_fax])
29 @contact = Contact.find_by_id(@contact_fax.contact_id)
30
31 if @contact_fax.save
32 flash[:notice] = "Successfully created contact fax."
33 pdf = Prawn::Document.new
34 pdf.font "Times-Roman"
35 pdf.move_down(20)
36 pdf.text "ATTN: #{@contact.first_name} #{@contact.last_name}"
37 pdf.text "RE: #{@contact_fax.subject}"
38 pdf.move_down(20)
39
40 pdf.text "#{@contact_fax.body}"
41
42 OutboundMailer.deliver_fax_email(@contact, @contact_fax,pdf)
43 @contact_fax.complete_todo
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment