Skip to content
This repository
Browse code

Refactor subject with i18n.

  • Loading branch information...
commit 5c3ef8c17dba23d000d301467b1a620811c940b6 1 parent ddfc072
authored January 23, 2010

Showing 1 changed file with 7 additions and 3 deletions. Show diff stats Hide diff stats

  1. 10  actionmailer/lib/action_mailer/base.rb
10  actionmailer/lib/action_mailer/base.rb
@@ -398,8 +398,7 @@ def mail(headers = {})
398 398
       m = @message
399 399
 
400 400
       # Get default subject from I18n if none is set
401  
-      headers[:subject] ||= I18n.t(:subject, :scope => [:actionmailer, mailer_name, action_name],
402  
-                                             :default => action_name.humanize)
  401
+      headers[:subject] ||= default_subject
403 402
 
404 403
       # Give preference to headers and fallbacks to the ones set in mail
405 404
       content_type = headers[:content_type] || m.content_type
@@ -418,7 +417,7 @@ def mail(headers = {})
418 417
         # Do something
419 418
       else
420 419
         # TODO Ensure that we don't need to pass I18n.locale as detail
421  
-        templates = self.class.template_root.find_all(action_name, {}, mailer_name)
  420
+        templates = self.class.template_root.find_all(action_name, {}, self.class.mailer_name)
422 421
 
423 422
         if templates.size == 1 && !m.has_attachments?
424 423
           content_type ||= templates[0].mime_type.to_s
@@ -449,6 +448,11 @@ def mail(headers = {})
449 448
       m
450 449
     end
451 450
 
  451
+    def default_subject
  452
+      mailer_scope = self.class.mailer_name.gsub('/', '.')
  453
+      I18n.t(:subject, :scope => [:actionmailer, mailer_scope, action_name], :default => action_name.humanize)
  454
+    end
  455
+
452 456
     def insert_part(container, template, charset)
453 457
       part = Mail::Part.new
454 458
       part.content_type = template.mime_type.to_s

0 notes on commit 5c3ef8c

Please sign in to comment.
Something went wrong with that request. Please try again.