Class: PrinterMailer

Inherits:
ActionMailer::Base
  • Object
show all
Defined in:
app/mailers/printer_mailer.rb

Instance Method Summary collapse

Instance Method Details

#send_print(usr, file, msg = nil, subj = nil) ⇒ Object



4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
# File 'app/mailers/printer_mailer.rb', line 4

def send_print usr, file, msg=nil, subj=nil
  @usr = usr
  fname = case file
  when /\/pdf.*$/; 'print%s.pdf' % DateTime.now.nsec
  else 'print%s.label' % DateTime.now.nsec
  end
  attachments[fname] = File.read(file) unless file.blank?
   = @usr..logos.first.image.url rescue ""
  attachments.inline['logo.png'] = File.read( File.join(Rails.root,'public',)) unless .blank?

  @msg = msg || "See attached PDF"
  subj ||= "Kontakt administrator! Der mangler en printer definition!"

  mail  from: '[email protected]',
        to: @usr.email,
        subject: subj
end