From 57bfbc249e2af753163788d07ac7a658b4f5484a Mon Sep 17 00:00:00 2001 From: Olek Janiszewski Date: Wed, 23 Jan 2013 19:22:39 +0100 Subject: Allow passing interpolations to `#default_i18n_subject`, e.g.: # config/locales/en.yml en: user_mailer: welcome: subject: 'Hello, %{username}' # app/mailers/user_mailer.rb class UserMailer < ActionMailer::Base def welcome(user) mail(subject: default_i18n_subject(username: user.name)) end end --- actionmailer/lib/action_mailer/base.rb | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'actionmailer/lib') diff --git a/actionmailer/lib/action_mailer/base.rb b/actionmailer/lib/action_mailer/base.rb index 9ba606c045..c4d2950abd 100644 --- a/actionmailer/lib/action_mailer/base.rb +++ b/actionmailer/lib/action_mailer/base.rb @@ -726,9 +726,10 @@ module ActionMailer # Translates the +subject+ using Rails I18n class under [mailer_scope, action_name] scope. # If it does not find a translation for the +subject+ under the specified scope it will default to a # humanized version of the action_name. - def default_i18n_subject #:nodoc: + # If the subject has interpolations, you can pass them through the +interpolations+ parameter. + def default_i18n_subject(interpolations = {}) mailer_scope = self.class.mailer_name.tr('/', '.') - I18n.t(:subject, scope: [mailer_scope, action_name], default: action_name.humanize) + I18n.t(:subject, interpolations.merge(scope: [mailer_scope, action_name], default: action_name.humanize)) end def collect_responses(headers) #:nodoc: -- cgit v1.2.3