diff options
author | yuuji.yaginuma <yuuji.yaginuma@gmail.com> | 2016-05-13 15:02:36 +0900 |
---|---|---|
committer | yuuji.yaginuma <yuuji.yaginuma@gmail.com> | 2016-05-15 08:11:07 +0900 |
commit | f0f4cb2f64566020b6edd48e0a81fd744ffc2e4c (patch) | |
tree | 644921c350b84d31de3dd3a7795543532c5597d7 /railties/lib/rails/generators | |
parent | 0991c4c6fc0c04764f34c6b65a42adce190440c3 (diff) | |
download | rails-f0f4cb2f64566020b6edd48e0a81fd744ffc2e4c.tar.gz rails-f0f4cb2f64566020b6edd48e0a81fd744ffc2e4c.tar.bz2 rails-f0f4cb2f64566020b6edd48e0a81fd744ffc2e4c.zip |
generate mailer layout files if it does not already exist
Currently, if `ApplicationMailer` does not exist, it is generated when
run the mailer generator, but layouts files does not generate.
However, because it uses the layouts in `ApplicationMailer`,
layouts are required.
Follow up to #24161
Diffstat (limited to 'railties/lib/rails/generators')
3 files changed, 21 insertions, 0 deletions
diff --git a/railties/lib/rails/generators/erb/mailer/mailer_generator.rb b/railties/lib/rails/generators/erb/mailer/mailer_generator.rb index 7f00943d80..97f3657070 100644 --- a/railties/lib/rails/generators/erb/mailer/mailer_generator.rb +++ b/railties/lib/rails/generators/erb/mailer/mailer_generator.rb @@ -9,6 +9,13 @@ 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', class_path, 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.tt b/railties/lib/rails/generators/erb/mailer/templates/layout.html.erb.tt new file mode 100644 index 0000000000..55f3675d49 --- /dev/null +++ b/railties/lib/rails/generators/erb/mailer/templates/layout.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.tt b/railties/lib/rails/generators/erb/mailer/templates/layout.text.erb.tt new file mode 100644 index 0000000000..6363733e6e --- /dev/null +++ b/railties/lib/rails/generators/erb/mailer/templates/layout.text.erb.tt @@ -0,0 +1 @@ +<%%= yield %> |