aboutsummaryrefslogtreecommitdiffstats
path: root/railties/lib/rails
diff options
context:
space:
mode:
authorDavid Heinemeier Hansson <david@loudthinking.com>2014-11-25 01:59:43 +0300
committerDavid Heinemeier Hansson <david@loudthinking.com>2014-11-25 01:59:43 +0300
commit35362fc2263d4d7784de172cb5f97eb2541fb65a (patch)
treee81260a3a7d9bea35fc091515162e307efc1893f /railties/lib/rails
parent9685080a7677abfa5d288a81c3e078368c6bb67c (diff)
parenta58da25d90962a39ad916fc4de22a0a0c81ba034 (diff)
downloadrails-35362fc2263d4d7784de172cb5f97eb2541fb65a.tar.gz
rails-35362fc2263d4d7784de172cb5f97eb2541fb65a.tar.bz2
rails-35362fc2263d4d7784de172cb5f97eb2541fb65a.zip
Merge pull request #17646 from andyjeffries/html_layout_fix
Creating mailer layouts by default, including html and body tags
Diffstat (limited to 'railties/lib/rails')
-rw-r--r--railties/lib/rails/generators/erb/mailer/mailer_generator.rb20
-rw-r--r--railties/lib/rails/generators/erb/mailer/templates/layout.html.erb5
-rw-r--r--railties/lib/rails/generators/erb/mailer/templates/layout.text.erb1
3 files changed, 26 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 66b17bd10e..1e290bb938 100644
--- a/railties/lib/rails/generators/erb/mailer/mailer_generator.rb
+++ b/railties/lib/rails/generators/erb/mailer/mailer_generator.rb
@@ -3,6 +3,26 @@ require 'rails/generators/erb/controller/controller_generator'
module Erb # :nodoc:
module Generators # :nodoc:
class MailerGenerator < ControllerGenerator # :nodoc:
+ def copy_view_files
+ view_base_path = File.join("app/views", class_path, file_name)
+ empty_directory view_base_path
+
+ layout_base_path = "app/views/layouts"
+
+ actions.each do |action|
+ @action = action
+
+ formats.each do |format|
+ @view_path = File.join(view_base_path, filename_with_extensions(action, format))
+ template filename_with_extensions(:view, format), @view_path
+
+ @layout_path = File.join(layout_base_path, filename_with_extensions("mailer", format))
+ template filename_with_extensions(:layout, format), @layout_path
+ end
+ end
+
+ end
+
protected
def formats
diff --git a/railties/lib/rails/generators/erb/mailer/templates/layout.html.erb b/railties/lib/rails/generators/erb/mailer/templates/layout.html.erb
new file mode 100644
index 0000000000..93110e74ad
--- /dev/null
+++ b/railties/lib/rails/generators/erb/mailer/templates/layout.html.erb
@@ -0,0 +1,5 @@
+<html>
+ <body>
+ <%%= yield %>
+ </body>
+</html>
diff --git a/railties/lib/rails/generators/erb/mailer/templates/layout.text.erb b/railties/lib/rails/generators/erb/mailer/templates/layout.text.erb
new file mode 100644
index 0000000000..6363733e6e
--- /dev/null
+++ b/railties/lib/rails/generators/erb/mailer/templates/layout.text.erb
@@ -0,0 +1 @@
+<%%= yield %>