i'm generating invoice pdf via wicket_pdf , works. pdf used attachment in email in later step of process.
# user.rb def send_last_invoice_email!(invoice) usermailer.send_actual_invoice_email(self, invoice).deliver end # user_mailer.rb def send_actual_invoice_email(user, invoice) @user = user @invoice = invoice = @user.email # problematic line attachments["#{@invoice.file_name}"] = file.read(@invoice.file_name_path) mail(:to => to) end # console => works user = user.where("step_id = 1 , status = 0").last invoice = user.invoices.last user.send_last_invoice_email!(invoice) # rake task => doesn't work desc "send email first user step_id => 1 testing purpose" task :send_mail => :environment user = user.where("step_id = 1 , status = 0").last invoice = user.invoices.last user.send_last_invoice_email!(invoice) end
when call rake task pdf empty. debugged , file name exists , original pdf file ok, attached pdf inside email empty.
i use letter_opener (1.0.0) in development mode.
does know, why there difference between console , executing same code via rake task? , how debug difference?
found problem. strange. found solution while comparing 2 pdfs in hex-editor.
in rake had set ruby standard encoding utf-8
# users.rake namespace :users encoding.default_external = encoding::utf_8 encoding.default_internal = encoding::utf_8 ...
i hope maybe others profit 2 days effort :-). cheers
Comments
Post a Comment