diff options
author | José Valim and Mikel Lindsaar <pair@programming.com> | 2010-01-23 10:24:19 +0100 |
---|---|---|
committer | José Valim and Mikel Lindsaar <pair@programming.com> | 2010-01-23 10:24:19 +0100 |
commit | 5c3ef8c17dba23d000d301467b1a620811c940b6 (patch) | |
tree | e9ef6f824581cc56794c3cb6b1dfdc924249d24d | |
parent | ddfc0725a062880131745a1c529e94541d4c9ee0 (diff) | |
download | rails-5c3ef8c17dba23d000d301467b1a620811c940b6.tar.gz rails-5c3ef8c17dba23d000d301467b1a620811c940b6.tar.bz2 rails-5c3ef8c17dba23d000d301467b1a620811c940b6.zip |
Refactor subject with i18n.
-rw-r--r-- | actionmailer/lib/action_mailer/base.rb | 10 |
1 files changed, 7 insertions, 3 deletions
diff --git a/actionmailer/lib/action_mailer/base.rb b/actionmailer/lib/action_mailer/base.rb index 98e559154a..94e20d4b63 100644 --- a/actionmailer/lib/action_mailer/base.rb +++ b/actionmailer/lib/action_mailer/base.rb @@ -398,8 +398,7 @@ module ActionMailer #:nodoc: m = @message # Get default subject from I18n if none is set - headers[:subject] ||= I18n.t(:subject, :scope => [:actionmailer, mailer_name, action_name], - :default => action_name.humanize) + headers[:subject] ||= default_subject # Give preference to headers and fallbacks to the ones set in mail content_type = headers[:content_type] || m.content_type @@ -418,7 +417,7 @@ module ActionMailer #:nodoc: # Do something else # TODO Ensure that we don't need to pass I18n.locale as detail - templates = self.class.template_root.find_all(action_name, {}, mailer_name) + templates = self.class.template_root.find_all(action_name, {}, self.class.mailer_name) if templates.size == 1 && !m.has_attachments? content_type ||= templates[0].mime_type.to_s @@ -449,6 +448,11 @@ module ActionMailer #:nodoc: m end + def default_subject + mailer_scope = self.class.mailer_name.gsub('/', '.') + I18n.t(:subject, :scope => [:actionmailer, mailer_scope, action_name], :default => action_name.humanize) + end + def insert_part(container, template, charset) part = Mail::Part.new part.content_type = template.mime_type.to_s |