1

Rails 3.2.14 アプリは本番環境でのみ動作が不安定です。次のエラー メッセージが表示され、電子メールの送信に失敗します。

ActionView::MissingTemplate (Missing template /invoice with {:locale=>[:en], :formats=>[:text], :handlers=>[:erb, :builder]}. Searched in:
  * "/var/www/appname/releases/20131003214241/app/views"
):
app/mailers/mailer.rb:42:in `block in invoice'
app/mailers/mailer.rb:41:in `invoice'
app/controllers/admin_controller.rb:410:in `resend_invoice'

Mailer#invoice メソッドは次のようになります。

def invoice(order, resent=false, receipt_or_invoice = "Receipt")
  @order = order
  @freebie = @order.freebie?
  @mail = true
  @transaction = @order.beanstream_transaction
  @user = @order.user
  recipient = @order.email_receipt_to || @user.email || "support@example.com"
  @receipt_or_invoice = receipt_or_invoice

  subject = @freebie ? "Your License" : "Your #{receipt_or_invoice.capitalize} and License     Information#{ resent ? " (Resent)" : ""}"
  mail = mail(:to => [recipient], :subject => subject)
  mail.add_part(Mail::Part.new do
    content_type 'multipart/alternative'
    # THE ODD BIT vv
    mail.parts.reverse!.delete_if {|p| add_part p }
  end)
  mail.content_type 'multipart/mixed'
  mail.header['content-type'].parameters[:boundary] = mail.body.boundary
  @order.line_items.each do |li|
    aq_data = li.license.aquatic_prime_data
    if aq_data.present?
      attachments[li.license.aquatic_prime_filename] = {content: aq_data, mime_type:     'application/xml'}
    end
  end
  return mail
end

いくつかのメモ。

  1. これは、Pow を使用した開発では問題なく動作します。本番環境では Apache+Passenger を使用しています。
  2. これ以前にメーラーに行った最後の変更は、6 月に新しいメソッドを追加することでした。メールの配信に失敗したという報告は他にありません。これは、何らかの形でこの問題を引き起こした ActionMailer または他の Rails gem で何かが変更されたと思われます。
  3. このエラーは、ストア コントローラーまたはコードの他の部分から Mailer.invoice が呼び出されたときにも発生するため、メーラーにローカライズされていると思います。
  4. 開発中は、メールの送信に Google SMTP サーバーを使用していますが、本番環境では Postmark を使用しています。

ヘルプや洞察をお寄せいただきありがとうございます。

4

1 に答える 1