diff options
author | José Valim <jose.valim@gmail.com> | 2010-04-30 12:11:38 +0200 |
---|---|---|
committer | José Valim <jose.valim@gmail.com> | 2010-04-30 12:11:38 +0200 |
commit | 7b98d2aa59e301c91d764262bba55133fef3538a (patch) | |
tree | 0965f8c87fd4222ecfa053d9547b523c0a57d146 /actionmailer/lib/rails | |
parent | d2a49e4b1f30c5997e169110eed94a55aee53f56 (diff) | |
download | rails-7b98d2aa59e301c91d764262bba55133fef3538a.tar.gz rails-7b98d2aa59e301c91d764262bba55133fef3538a.tar.bz2 rails-7b98d2aa59e301c91d764262bba55133fef3538a.zip |
Reorganize the mailer generator a bit.
Diffstat (limited to 'actionmailer/lib/rails')
3 files changed, 49 insertions, 0 deletions
diff --git a/actionmailer/lib/rails/generators/mailer/USAGE b/actionmailer/lib/rails/generators/mailer/USAGE new file mode 100644 index 0000000000..a08d459739 --- /dev/null +++ b/actionmailer/lib/rails/generators/mailer/USAGE @@ -0,0 +1,15 @@ +Description: + Stubs out a new mailer and its views. Pass the mailer name, either + CamelCased or under_scored, and an optional list of emails as arguments. + + This generates a mailer class in app/mailers and invokes your template + engine and test framework generators. + +Example: + `rails generate mailer Notifications signup forgot_password invoice` + + creates a Notifications mailer class, views, test, and fixtures: + Mailer: app/mailers/notifications.rb + Views: app/views/notifications/signup.erb [...] + Test: test/functional/notifications_test.rb + Fixtures: test/fixtures/notifications/signup [...] diff --git a/actionmailer/lib/rails/generators/mailer/mailer_generator.rb b/actionmailer/lib/rails/generators/mailer/mailer_generator.rb new file mode 100644 index 0000000000..8f47539f42 --- /dev/null +++ b/actionmailer/lib/rails/generators/mailer/mailer_generator.rb @@ -0,0 +1,18 @@ +module Rails + module Generators + class MailerGenerator < NamedBase + argument :actions, :type => :array, :default => [], :banner => "method method" + check_class_collision + + def self.source_root + File.expand_path("../templates", __FILE__) + end + + def create_mailer_file + template "mailer.rb", File.join('app/mailers', class_path, "#{file_name}.rb") + end + + hook_for :template_engine, :test_framework + end + end +end diff --git a/actionmailer/lib/rails/generators/mailer/templates/mailer.rb b/actionmailer/lib/rails/generators/mailer/templates/mailer.rb new file mode 100644 index 0000000000..7343eb28b3 --- /dev/null +++ b/actionmailer/lib/rails/generators/mailer/templates/mailer.rb @@ -0,0 +1,16 @@ +class <%= class_name %> < ActionMailer::Base + default :from => "from@example.com" +<% for action in actions -%> + + # Subject can be set in your I18n file at config/locales/en.yml + # with the following lookup: + # + # en.actionmailer.<%= file_name %>.<%= action %>.subject + # + def <%= action %> + @greeting = "Hi" + + mail :to => "to@example.org" + end +<% end -%> +end |