Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Refactor subject with i18n.

  • Loading branch information...
commit 5c3ef8c17dba23d000d301467b1a620811c940b6 1 parent ddfc072
José Valim and Mikel Lindsaar authored
Showing with 7 additions and 3 deletions.
  1. +7 −3 actionmailer/lib/action_mailer/base.rb
View
10 actionmailer/lib/action_mailer/base.rb
@@ -398,8 +398,7 @@ def mail(headers = {})
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 @@ def mail(headers = {})
# 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 @@ def mail(headers = {})
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
Please sign in to comment.
Something went wrong with that request. Please try again.