lib/action_mailer/base.rb in actionmailer-0.5.0 vs lib/action_mailer/base.rb in actionmailer-0.6.0

- old
+ new

@@ -84,10 +84,11 @@ cattr_accessor :deliveries attr_accessor :recipients, :subject, :body, :from, :sent_on, :headers, :bcc, :cc def initialize + @bcc = @cc = @from = @recipients = @sent_on = @subject = @body = nil @headers = {} end class << self def method_missing(method_symbol, *parameters)#:nodoc: @@ -145,18 +146,19 @@ def create_from_action(method_name, *parameters) mailer = new mailer.body = {} mailer.send(method_name, *parameters) - if String === mailer.body - mail = create(mailer.recipients, mailer.subject, mailer.body, mailer.from, mailer.sent_on, mailer.headers) - else - mail = create(mailer.recipients, mailer.subject, render_body(mailer, method_name), mailer.from, mailer.sent_on, mailer.headers) + unless String === mailer.body then + mailer.body = render_body mailer, method_name end - mail.bcc = @bcc if @bcc - mail.cc = @cc if @cc - + mail = create(mailer.recipients, mailer.subject, mailer.body, + mailer.from, mailer.sent_on, mailer.headers) + + mail.bcc = mailer.bcc unless mailer.bcc.nil? + mail.cc = mailer.cc unless mailer.cc.nil? + return mail end def render_body(mailer, method_name) ActionView::Base.new(template_path, mailer.body).render_file(method_name)