aboutsummaryrefslogtreecommitdiffstats
path: root/railties/guides/source/action_mailer_basics.textile
diff options
context:
space:
mode:
authorAlberto Perdomo <alberto.perdomo@aentos.es>2011-06-23 17:57:48 +0100
committerAlberto Perdomo <alberto.perdomo@aentos.es>2011-06-23 17:57:48 +0100
commitf1d77bad265bd3f8f2c621c69613909e46e9e6ea (patch)
tree93b460a057661e7ffb18624f947820dceb162334 /railties/guides/source/action_mailer_basics.textile
parent1f505a8ef21a300c22e4c6a3cc4d3bf4cf1853de (diff)
downloadrails-f1d77bad265bd3f8f2c621c69613909e46e9e6ea.tar.gz
rails-f1d77bad265bd3f8f2c621c69613909e46e9e6ea.tar.bz2
rails-f1d77bad265bd3f8f2c621c69613909e46e9e6ea.zip
Action Mailer Basics Guide: Added example on using mail(:template_path => ..., :template_name => ...) to specify custom template files.
Diffstat (limited to 'railties/guides/source/action_mailer_basics.textile')
-rw-r--r--railties/guides/source/action_mailer_basics.textile25
1 files changed, 23 insertions, 2 deletions
diff --git a/railties/guides/source/action_mailer_basics.textile b/railties/guides/source/action_mailer_basics.textile
index e1ff49cd60..2eaee158ff 100644
--- a/railties/guides/source/action_mailer_basics.textile
+++ b/railties/guides/source/action_mailer_basics.textile
@@ -284,16 +284,37 @@ class UserMailer < ActionMailer::Base
@user = user
@url = "http://example.com/login"
mail(:to => user.email,
+ :subject => "Welcome to My Awesome Site",
+ :template_path => 'notifications',
+ :template_name => 'another')
+ end
+ end
+
+end
+</ruby>
+
+In this case it will look for templates at +app/views/notifications+ with name +another+.
+
+If you want more flexibility you can also pass a block and render specific templates or even render inline or text without using a template file:
+
+<ruby>
+class UserMailer < ActionMailer::Base
+ default :from => "notifications@example.com"
+
+ def welcome_email(user)
+ @user = user
+ @url = "http://example.com/login"
+ mail(:to => user.email,
:subject => "Welcome to My Awesome Site") do |format|
format.html { render 'another_template' }
- format.text { render 'another_template' }
+ format.text { render :text => 'Render text' }
end
end
end
</ruby>
-Will render 'another_template.text.erb' and 'another_template.html.erb'. The render command is the same one used inside of Action Controller, so you can use all the same options, such as <tt>:text</tt> etc.
+This will render the template 'another_template.html.erb' for the HTML part and use the rendered text for the text part. The render command is the same one used inside of Action Controller, so you can use all the same options, such as <tt>:text</tt>, <tt>:inline</tt> etc.
h4. Action Mailer Layouts