diff options
Diffstat (limited to 'actionmailer/lib/rails')
-rw-r--r-- | actionmailer/lib/rails/generators/mailer/mailer_generator.rb | 13 | ||||
-rw-r--r-- | actionmailer/lib/rails/generators/mailer/templates/application_mailer.rb | 2 |
2 files changed, 13 insertions, 2 deletions
diff --git a/actionmailer/lib/rails/generators/mailer/mailer_generator.rb b/actionmailer/lib/rails/generators/mailer/mailer_generator.rb index f86d43be61..01bdfb0685 100644 --- a/actionmailer/lib/rails/generators/mailer/mailer_generator.rb +++ b/actionmailer/lib/rails/generators/mailer/mailer_generator.rb @@ -11,8 +11,8 @@ module Rails template "mailer.rb", File.join('app/mailers', class_path, "#{file_name}_mailer.rb") in_root do - if self.behavior == :invoke && !File.exist?('app/mailers/application_mailer.rb') - template 'application_mailer.rb', 'app/mailers/application_mailer.rb' + if self.behavior == :invoke && !File.exist?(application_mailer_file_name) + template 'application_mailer.rb', application_mailer_file_name end end end @@ -23,6 +23,15 @@ module Rails def file_name @_file_name ||= super.gsub(/_mailer/i, '') end + + private + def application_mailer_file_name + @_application_mailer_file_name ||= if mountable_engine? + "app/mailers/#{namespaced_path}/application_mailer.rb" + else + "app/mailers/application_mailer.rb" + end + end end end end diff --git a/actionmailer/lib/rails/generators/mailer/templates/application_mailer.rb b/actionmailer/lib/rails/generators/mailer/templates/application_mailer.rb index 02e8d3e454..93fd9a7449 100644 --- a/actionmailer/lib/rails/generators/mailer/templates/application_mailer.rb +++ b/actionmailer/lib/rails/generators/mailer/templates/application_mailer.rb @@ -1,4 +1,6 @@ +<% module_namespacing do %> class ApplicationMailer < ActionMailer::Base default from: 'from@example.com' layout :mailer end +<% end %> |