From dda6787f44a4e9a90cc28b3efee5b63c7d8cd023 Mon Sep 17 00:00:00 2001
From: Vijay Dev <vijaydev.cse@gmail.com>
Date: Sat, 19 Nov 2011 00:07:50 +0530
Subject: mailer guide - update info about using default host. Fixes #3642

---
 railties/guides/source/action_mailer_basics.textile | 15 ++++-----------
 1 file changed, 4 insertions(+), 11 deletions(-)

(limited to 'railties/guides/source/action_mailer_basics.textile')

diff --git a/railties/guides/source/action_mailer_basics.textile b/railties/guides/source/action_mailer_basics.textile
index ad5b848d2c..26c95be031 100644
--- a/railties/guides/source/action_mailer_basics.textile
+++ b/railties/guides/source/action_mailer_basics.textile
@@ -362,21 +362,14 @@ When using named routes you only need to supply the +:host+:
 
 Email clients have no web context and so paths have no base URL to form complete web addresses. Thus, when using named routes only the "_url" variant makes sense.
 
-It is also possible to set a default host that will be used in all mailers by setting the +:host+ option in the +ActionMailer::Base.default_url_options+ hash as follows:
+It is also possible to set a default host that will be used in all mailers by setting the <tt>:host</tt> option as a configuration option in <tt>config/application.rb</tt>:
 
 <ruby>
-class UserMailer < ActionMailer::Base
-  default_url_options[:host] = "example.com"
-
-  def welcome_email(user)
-    @user = user
-    @url  = user_url(@user)
-    mail(:to => user.email,
-         :subject => "Welcome to My Awesome Site")
-  end
-end
+config.action_mailer.default_url_options = { :host => "example.com" }
 </ruby>
 
+If you use this setting, you should pass the <tt>:only_path => false</tt> option when using +url_for+. This will ensure that absolute URLs are generated because the +url_for+ view helper will, by default, generate relative URLs when a <tt>:host</tt> option isn't explicitly provided.
+
 h4. Sending Multipart Emails
 
 Action Mailer will automatically send multipart emails if you have different templates for the same action. So, for our UserMailer example, if you have +welcome_email.text.erb+ and +welcome_email.html.erb+ in +app/views/user_mailer+, Action Mailer will automatically send a multipart email with the HTML and text versions setup as different parts.
-- 
cgit v1.2.3

