aboutsummaryrefslogtreecommitdiffstats
path: root/actionmailer/lib
diff options
context:
space:
mode:
authorCarlos Souza <carloshrsouza@gmail.com>2014-12-17 13:18:22 -0500
committerCarlos Souza <carloshrsouza@gmail.com>2015-01-06 10:46:22 -0500
commit5697bdbb6da5d08e541a3b12251cec90269b059b (patch)
tree3a98e7d3bb11826ab8cb7c05e887cd21e46e71ec /actionmailer/lib
parent52f641264b1325a4c2bdce7971b14524bd4905f1 (diff)
downloadrails-5697bdbb6da5d08e541a3b12251cec90269b059b.tar.gz
rails-5697bdbb6da5d08e541a3b12251cec90269b059b.tar.bz2
rails-5697bdbb6da5d08e541a3b12251cec90269b059b.zip
Add mailer suffix to generated files and classes
Following the same naming convention used in controllers and jobs.
Diffstat (limited to 'actionmailer/lib')
-rw-r--r--actionmailer/lib/rails/generators/mailer/USAGE2
-rw-r--r--actionmailer/lib/rails/generators/mailer/mailer_generator.rb10
-rw-r--r--actionmailer/lib/rails/generators/mailer/templates/mailer.rb2
3 files changed, 10 insertions, 4 deletions
diff --git a/actionmailer/lib/rails/generators/mailer/USAGE b/actionmailer/lib/rails/generators/mailer/USAGE
index 323bb8a87f..d9d9d064d8 100644
--- a/actionmailer/lib/rails/generators/mailer/USAGE
+++ b/actionmailer/lib/rails/generators/mailer/USAGE
@@ -11,7 +11,7 @@ Example:
rails generate mailer Notifications signup forgot_password invoice
creates a Notifications mailer class, views, and test:
- Mailer: app/mailers/notifications.rb
+ Mailer: app/mailers/notifications_mailer.rb
Views: app/views/notifications/signup.text.erb [...]
Test: test/mailers/notifications_test.rb
diff --git a/actionmailer/lib/rails/generators/mailer/mailer_generator.rb b/actionmailer/lib/rails/generators/mailer/mailer_generator.rb
index 83f8a67da7..3ec7d3d896 100644
--- a/actionmailer/lib/rails/generators/mailer/mailer_generator.rb
+++ b/actionmailer/lib/rails/generators/mailer/mailer_generator.rb
@@ -4,16 +4,22 @@ module Rails
source_root File.expand_path("../templates", __FILE__)
argument :actions, type: :array, default: [], banner: "method method"
- check_class_collision
+
+ check_class_collision suffix: "Mailer"
def create_mailer_file
- template "mailer.rb", File.join('app/mailers', class_path, "#{file_name}.rb")
+ template "mailer.rb", File.join('app/mailers', class_path, "#{file_name}_mailer.rb")
if self.behavior == :invoke
template "application_mailer.rb", 'app/mailers/application_mailer.rb'
end
end
hook_for :template_engine, :test_framework
+
+ protected
+ def file_name
+ @_file_name ||= super.gsub(/\_mailer/i, '')
+ end
end
end
end
diff --git a/actionmailer/lib/rails/generators/mailer/templates/mailer.rb b/actionmailer/lib/rails/generators/mailer/templates/mailer.rb
index bce64a5e6e..b9be70a2f0 100644
--- a/actionmailer/lib/rails/generators/mailer/templates/mailer.rb
+++ b/actionmailer/lib/rails/generators/mailer/templates/mailer.rb
@@ -1,5 +1,5 @@
<% module_namespacing do -%>
-class <%= class_name %> < ApplicationMailer
+class <%= class_name %>Mailer < ApplicationMailer
<% actions.each do |action| -%>
# Subject can be set in your I18n file at config/locales/en.yml