1

複数のメーラー「アクション」に同じアクション メーラー テンプレートを再利用するにはどうすればよいですか?

ActionController では、次のことができます

...
render :action => 'another_action'

ActionMailer でも同じことができると思いますが、正しい方法を見つけることができなかったようです。関連がある場合、私は Rails 2.3.2 を使用しています。

ありがとう!

4

1 に答える 1

1

あなたはrender_messageを探しています、API DocsMultipartMessageセクションに良い例があります-以下に貼り付けられています。

class ApplicationMailer < ActionMailer::Base
  def signup_notification(recipient)
    recipients      recipient.email_address_with_name
    subject         "New account information"
    from            "system@example.com"
    content_type    "multipart/alternative"

    part :content_type => "text/html",
      :body => render_message("signup-as-html", :account => recipient)

    part "text/plain" do |p|
      p.body = render_message("signup-as-plain", :account => recipient)
      p.transfer_encoding = "base64"
    end
  end
end
于 2009-08-25T03:43:47.113 に答える