diff options
author | Rafael França <rafaelmfranca@gmail.com> | 2015-12-17 18:12:23 -0200 |
---|---|---|
committer | Rafael França <rafaelmfranca@gmail.com> | 2015-12-17 18:12:23 -0200 |
commit | 9446e38ba47c9ca3be2ad668d8a8bea0141be6fc (patch) | |
tree | bce7c44434725163237ee4b6d2acf8cf71977cb1 /railties/lib | |
parent | b611350e7c9e5aefd3ea55c9c041f15f0f774b47 (diff) | |
parent | 293d35e256d282e3ea9d4d6277611e1e4d50dc96 (diff) | |
download | rails-9446e38ba47c9ca3be2ad668d8a8bea0141be6fc.tar.gz rails-9446e38ba47c9ca3be2ad668d8a8bea0141be6fc.tar.bz2 rails-9446e38ba47c9ca3be2ad668d8a8bea0141be6fc.zip |
Merge pull request #22627 from rails/application-mailer-by-default
ApplicationMailer should be generated by default just like every other Application* parent
Diffstat (limited to 'railties/lib')
-rw-r--r-- | railties/lib/rails/generators/erb/mailer/mailer_generator.rb | 7 | ||||
-rw-r--r-- | railties/lib/rails/generators/erb/mailer/templates/layout.html.erb | 5 | ||||
-rw-r--r-- | railties/lib/rails/generators/rails/app/app_generator.rb | 10 | ||||
-rw-r--r-- | railties/lib/rails/generators/rails/app/templates/app/mailers/application_mailer.rb | 4 | ||||
-rw-r--r-- | railties/lib/rails/generators/rails/app/templates/app/views/layouts/mailer.html.erb.tt | 13 | ||||
-rw-r--r-- | railties/lib/rails/generators/rails/app/templates/app/views/layouts/mailer.text.erb.tt (renamed from railties/lib/rails/generators/erb/mailer/templates/layout.text.erb) | 0 |
6 files changed, 25 insertions, 14 deletions
diff --git a/railties/lib/rails/generators/erb/mailer/mailer_generator.rb b/railties/lib/rails/generators/erb/mailer/mailer_generator.rb index 65563aa6db..bc249aa5e5 100644 --- a/railties/lib/rails/generators/erb/mailer/mailer_generator.rb +++ b/railties/lib/rails/generators/erb/mailer/mailer_generator.rb @@ -9,13 +9,6 @@ module Erb # :nodoc: view_base_path = File.join("app/views", class_path, file_name + '_mailer') empty_directory view_base_path - if self.behavior == :invoke - formats.each do |format| - layout_path = File.join("app/views/layouts", filename_with_extensions("mailer", format)) - template filename_with_extensions(:layout, format), layout_path - end - end - actions.each do |action| @action = action diff --git a/railties/lib/rails/generators/erb/mailer/templates/layout.html.erb b/railties/lib/rails/generators/erb/mailer/templates/layout.html.erb deleted file mode 100644 index 93110e74ad..0000000000 --- a/railties/lib/rails/generators/erb/mailer/templates/layout.html.erb +++ /dev/null @@ -1,5 +0,0 @@ -<html> - <body> - <%%= yield %> - </body> -</html> diff --git a/railties/lib/rails/generators/rails/app/app_generator.rb b/railties/lib/rails/generators/rails/app/app_generator.rb index 2a3f16c02e..44bbc478d0 100644 --- a/railties/lib/rails/generators/rails/app/app_generator.rb +++ b/railties/lib/rails/generators/rails/app/app_generator.rb @@ -59,8 +59,6 @@ module Rails keep_file 'app/assets/images' keep_file 'app/assets/javascripts/channels' unless options[:skip_action_cable] - keep_file 'app/mailers' - keep_file 'app/controllers/concerns' keep_file 'app/models/concerns' end @@ -301,6 +299,14 @@ module Rails end end + def delete_action_mailer_files_skipping_action_mailer + if options[:skip_action_mailer] + remove_file 'app/mailers/application_mailer.rb' + remove_file 'app/views/layouts/mailer.html.erb' + remove_file 'app/views/layouts/mailer.text.erb' + end + end + def delete_active_record_initializers_skipping_active_record if options[:skip_active_record] remove_file 'config/initializers/active_record_belongs_to_required_by_default.rb' diff --git a/railties/lib/rails/generators/rails/app/templates/app/mailers/application_mailer.rb b/railties/lib/rails/generators/rails/app/templates/app/mailers/application_mailer.rb new file mode 100644 index 0000000000..286b2239d1 --- /dev/null +++ b/railties/lib/rails/generators/rails/app/templates/app/mailers/application_mailer.rb @@ -0,0 +1,4 @@ +class ApplicationMailer < ActionMailer::Base + default from: 'from@example.com' + layout 'mailer' +end diff --git a/railties/lib/rails/generators/rails/app/templates/app/views/layouts/mailer.html.erb.tt b/railties/lib/rails/generators/rails/app/templates/app/views/layouts/mailer.html.erb.tt new file mode 100644 index 0000000000..55f3675d49 --- /dev/null +++ b/railties/lib/rails/generators/rails/app/templates/app/views/layouts/mailer.html.erb.tt @@ -0,0 +1,13 @@ +<!DOCTYPE html> +<html> + <head> + <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> + <style> + /* Email styles need to be inline */ + </style> + </head> + + <body> + <%%= yield %> + </body> +</html> diff --git a/railties/lib/rails/generators/erb/mailer/templates/layout.text.erb b/railties/lib/rails/generators/rails/app/templates/app/views/layouts/mailer.text.erb.tt index 6363733e6e..6363733e6e 100644 --- a/railties/lib/rails/generators/erb/mailer/templates/layout.text.erb +++ b/railties/lib/rails/generators/rails/app/templates/app/views/layouts/mailer.text.erb.tt |