From 5c54db290f4e7cdd69b461d4c0b020a9cd364537 Mon Sep 17 00:00:00 2001 From: Marcus Ilgner Date: Tue, 8 Dec 2015 12:28:00 +0100 Subject: ActionMailer: support overriding template name in multipart Implicit rendering in multipart blocks now also uses the template name from the options hash instead of always using the action name. So you can now write mail(template_name: template_name) do |format| format.text format.html end --- actionmailer/lib/action_mailer/base.rb | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) (limited to 'actionmailer/lib') diff --git a/actionmailer/lib/action_mailer/base.rb b/actionmailer/lib/action_mailer/base.rb index cbbf480da8..9dd3f151ad 100644 --- a/actionmailer/lib/action_mailer/base.rb +++ b/actionmailer/lib/action_mailer/base.rb @@ -893,9 +893,7 @@ module ActionMailer def collect_responses(headers) if block_given? - collector = ActionMailer::Collector.new(lookup_context) { render(action_name) } - yield(collector) - collector.responses + collect_responses_from_block(headers, &Proc.new) elsif headers[:body] [{ body: headers.delete(:body), @@ -906,6 +904,13 @@ module ActionMailer end end + def collect_responses_from_block(headers) + templates_name = headers[:template_name] || action_name + collector = ActionMailer::Collector.new(lookup_context) { render(templates_name) } + yield(collector) + collector.responses + end + def collect_responses_from_templates(headers) templates_path = headers[:template_path] || self.class.mailer_name templates_name = headers[:template_name] || action_name -- cgit v1.2.3