diff options
author | Pratik Naik <pratiknaik@gmail.com> | 2009-01-31 21:25:15 +0000 |
---|---|---|
committer | Pratik Naik <pratiknaik@gmail.com> | 2009-01-31 21:25:15 +0000 |
commit | cfddbcd8e7a1d965c937c04bbf6112b60d1bb962 (patch) | |
tree | 0063c5eaf2552c8d4d37fc42a851b3af4e67eae8 /railties/doc/guides/html/action_mailer_basics.html | |
parent | 9f097e3c83d36607bad55e2da8fcf2a2845a772e (diff) | |
download | rails-cfddbcd8e7a1d965c937c04bbf6112b60d1bb962.tar.gz rails-cfddbcd8e7a1d965c937c04bbf6112b60d1bb962.tar.bz2 rails-cfddbcd8e7a1d965c937c04bbf6112b60d1bb962.zip |
Regenerate guides html
Diffstat (limited to 'railties/doc/guides/html/action_mailer_basics.html')
-rw-r--r-- | railties/doc/guides/html/action_mailer_basics.html | 237 |
1 files changed, 209 insertions, 28 deletions
diff --git a/railties/doc/guides/html/action_mailer_basics.html b/railties/doc/guides/html/action_mailer_basics.html index c788591f72..22b575af45 100644 --- a/railties/doc/guides/html/action_mailer_basics.html +++ b/railties/doc/guides/html/action_mailer_basics.html @@ -47,8 +47,12 @@ <li><a href="#_action_mailer_layouts">Action Mailer Layouts</a></li> + <li><a href="#_generating_url_8217_s_in_action_mailer_views">Generating URL’s in Action Mailer views</a></li> + <li><a href="#_sending_multipart_emails">Sending multipart emails</a></li> + <li><a href="#_sending_emails_with_attachments">Sending emails with attachments</a></li> + </ul> </li> <li> @@ -75,9 +79,6 @@ <li> <a href="#_epilogue">Epilogue</a> </li> - <li> - <a href="#_changelog">Changelog</a> - </li> </ol> </div> @@ -85,19 +86,19 @@ <h1>Action Mailer Basics</h1> <div id="preamble">
<div class="sectionbody">
-<div class="paragraph"><p>This guide should provide you with all you need to get started in sending emails from your application, and will also cover how to test your mailers.</p></div>
+<div class="paragraph"><p>This guide should provide you with all you need to get started in sending and receiving emails from/to your application, and many internals of the ActionMailer class. It will also cover how to test your mailers.</p></div>
</div>
</div>
<h2 id="_introduction">1. Introduction</h2>
<div class="sectionbody">
<div class="paragraph"><p>Action Mailer allows you to send email from your application using a mailer model and views.
-Yes, that is correct, in Rails, emails are used by creating Models that inherit from ActionMailer::Base. They live alongside other models in /app/models BUT they have views just like controllers that appear alongside other views in app/views.</p></div>
+Yes, that is correct, in Rails, emails are used by creating models that inherit from ActionMailer::Base. They live alongside other models in /app/models BUT they have views just like controllers that appear alongside other views in app/views.</p></div>
</div>
<h2 id="_sending_emails">2. Sending Emails</h2>
<div class="sectionbody">
<div class="paragraph"><p>Let’s say you want to send a welcome email to a user after they signup. Here is how you would go about this:</p></div>
<h3 id="_walkthrough_to_generating_a_mailer">2.1. Walkthrough to generating a Mailer</h3>
-<h4 id="_1_create_the_mailer">2.1.1. 1. Create the mailer:</h4>
+<h4 id="_create_the_mailer">2.1.1. Create the mailer:</h4>
<div class="listingblock">
<div class="content"><!-- Generator: GNU source-highlight 2.9
by Lorenzo Bettini
@@ -111,7 +112,8 @@ create test/fixtures/user_mailer create app/models/user_mailer<span style="color: #990000">.</span>rb
create test/unit/user_mailer_test<span style="color: #990000">.</span>rb</tt></pre></div></div>
<div class="paragraph"><p>So we got the model, the fixtures, and the tests all created for us</p></div>
-<h4 id="_2_edit_the_model">2.1.2. 2. Edit the model:</h4>
+<h4 id="_edit_the_model">2.1.2. Edit the model:</h4>
+<div class="paragraph"><p>If you look at app/models/user_mailer.rb, you will see:</p></div>
<div class="listingblock">
<div class="content"><!-- Generator: GNU source-highlight 2.9
by Lorenzo Bettini
@@ -138,14 +140,40 @@ http://www.gnu.org/software/src-highlite --> <span style="font-weight: bold"><span style="color: #0000FF">end</span></span>
<span style="font-weight: bold"><span style="color: #0000FF">end</span></span></tt></pre></div></div>
-<div class="paragraph"><p>So what do we have here?
-recipients: who the recipients are, put in an array for multiple, ie, @recipients = ["user1@example.com", "user2@example.com"]
-from: Who the email will appear to come from in the recipients' mailbox
-subject: The subject of the email
-sent_on: Timestamp for the email
-content_type: The content type, by default is text/plain</p></div>
+<div class="paragraph"><p>So what do we have here?</p></div>
+<div class="tableblock">
+<table rules="all"
+width="100%"
+frame="border"
+cellspacing="0" cellpadding="4">
+<col width="20%" />
+<col width="80%" />
+<tbody valign="top">
+<tr>
+<td align="left"><p class="table">recipients</p></td>
+<td align="left"><p class="table">who the recipients are, put in an array for multiple, ie, @recipients = ["user1@example.com", "user2@example.com"]</p></td>
+</tr>
+<tr>
+<td align="left"><p class="table">from</p></td>
+<td align="left"><p class="table">Who the email will appear to come from in the recipients' mailbox</p></td>
+</tr>
+<tr>
+<td align="left"><p class="table">subject</p></td>
+<td align="left"><p class="table">The subject of the email</p></td>
+</tr>
+<tr>
+<td align="left"><p class="table">sent_on</p></td>
+<td align="left"><p class="table">Timestamp for the email</p></td>
+</tr>
+<tr>
+<td align="left"><p class="table">content_type</p></td>
+<td align="left"><p class="table">The content type, by default is text/plain</p></td>
+</tr>
+</tbody>
+</table>
+</div>
<div class="paragraph"><p>How about @body[:user]? Well anything you put in the @body hash will appear in the mailer view (more about mailer views below) as an instance variable ready for you to use, ie, in our example the mailer view will have a @user instance variable available for its consumption.</p></div>
-<h4 id="_3_create_the_mailer_view">2.1.3. 3. Create the mailer view</h4>
+<h4 id="_create_the_mailer_view">2.1.3. Create the mailer view</h4>
<div class="paragraph"><p></p></div>
<div class="paragraph"><p>The file can look like:</p></div>
<div class="listingblock">
@@ -160,7 +188,6 @@ http://www.gnu.org/software/src-highlite --> <span style="font-weight: bold"><span style="color: #0000FF"></head></span></span>
<span style="font-weight: bold"><span style="color: #0000FF"><body></span></span>
<span style="font-weight: bold"><span style="color: #0000FF"><h1></span></span>Welcome to example.com, <%= @user.first_name %><span style="font-weight: bold"><span style="color: #0000FF"></h1></span></span>
-
<span style="font-weight: bold"><span style="color: #0000FF"><p></span></span>
You have successfully signed up to example.com, and your username is: <%= @user.login %>.<span style="font-weight: bold"><span style="color: #0000FF"><br/></span></span>
To login to the site, just follow this link: <%= @url %>.
@@ -168,9 +195,10 @@ http://www.gnu.org/software/src-highlite --> <span style="font-weight: bold"><span style="color: #0000FF"><p></span></span>Thanks for joining and have a great day!<span style="font-weight: bold"><span style="color: #0000FF"></p></span></span>
<span style="font-weight: bold"><span style="color: #0000FF"></body></span></span>
<span style="font-weight: bold"><span style="color: #0000FF"></html></span></span></tt></pre></div></div>
-<h4 id="_4_wire_it_up_so_that_the_system_sends_the_email_when_a_user_signs_up">2.1.4. 4. Wire it up so that the system sends the email when a user signs up</h4>
-<div class="paragraph"><p>There are 3 was to achieve this. One is to send the email from the controller that sends the email, another is to put it in a before_create block in the user model, and the last one is to use an observer on the user model. Whether you use the second or third methods is up to you, but staying away from the first is recommended. Not because it’s wrong, but because it keeps your controller clean, and keeps all logic related to the user model within the user model. This way, whichever way a user is created (from a web form, or from an API call, for example), we are guaranteed that the email will be sent.</p></div>
-<div class="paragraph"><p></p></div>
+<h4 id="_wire_it_up_so_that_the_system_sends_the_email_when_a_user_signs_up">2.1.4. Wire it up so that the system sends the email when a user signs up</h4>
+<div class="paragraph"><p>There are 3 ways to achieve this. One is to send the email from the controller that sends the email, another is to put it in a before_create block in the user model, and the last one is to use an observer on the user model. Whether you use the second or third methods is up to you, but staying away from the first is recommended. Not because it’s wrong, but because it keeps your controller clean, and keeps all logic related to the user model within the user model. This way, whichever way a user is created (from a web form, or from an API call, for example), we are guaranteed that the email will be sent.</p></div>
+<div class="paragraph"><p>Let’s see how we would go about wiring it up using an observer:</p></div>
+<div class="paragraph"><p>In config/environment.rb:</p></div>
<div class="listingblock">
<div class="content"><!-- Generator: GNU source-highlight 2.9
by Lorenzo Bettini
@@ -185,7 +213,7 @@ Rails<span style="color: #990000">::</span>Initializer<span style="color: #99000 config<span style="color: #990000">.</span>active_record<span style="color: #990000">.</span>observers <span style="color: #990000">=</span> <span style="color: #990000">:</span>user_observer
<span style="font-weight: bold"><span style="color: #0000FF">end</span></span></tt></pre></div></div>
-<div class="paragraph"><p></p></div>
+<div class="paragraph"><p>There was a bit of a debate on where to put observers. Some people put them in app/models, but a cleaner method may be to create an app/observers folder to store all observers, and add that to your load path. Open config/environment.rb and make it look like:</p></div>
<div class="listingblock">
<div class="content"><!-- Generator: GNU source-highlight 2.9
by Lorenzo Bettini
@@ -202,7 +230,8 @@ Rails<span style="color: #990000">::</span>Initializer<span style="color: #99000 config<span style="color: #990000">.</span>active_record<span style="color: #990000">.</span>observers <span style="color: #990000">=</span> <span style="color: #990000">:</span>user_observer
<span style="font-weight: bold"><span style="color: #0000FF">end</span></span></tt></pre></div></div>
-<div class="paragraph"><p>ALMOST THERE :) Now all we need is that danged observer, and we’re done:</p></div>
+<div class="paragraph"><p>ALMOST THERE :) Now all we need is that danged observer, and we’re done:
+Create a file called user_observer in app/models or app/observers depending on where you stored it, and make it look like:</p></div>
<div class="listingblock">
<div class="content"><!-- Generator: GNU source-highlight 2.9
by Lorenzo Bettini
@@ -237,7 +266,7 @@ http://www.gnu.org/software/src-highlite --> <span style="font-weight: bold"><span style="color: #0000FF">else</span></span> <span style="font-weight: bold"><span style="color: #0000FF">super</span></span>
<span style="font-weight: bold"><span style="color: #0000FF">end</span></span>
<span style="font-weight: bold"><span style="color: #0000FF">end</span></span></tt></pre></div></div>
-<div class="paragraph"><p>Ah, this makes things so much clearer :) so if the method name starts with deliver_ followed by any combination of lowercase letters or underscore, method missing calls new on your mailer class UserMailer in our example above, sending the combination of lower case letters or underscore, along with the parameter. The resulting object is then sent the deliver! method, which well... delivers it.</p></div>
+<div class="paragraph"><p>Ah, this makes things so much clearer :) so if the method name starts with deliver_ followed by any combination of lowercase letters or underscore, method missing calls new on your mailer class (UserMailer in our example above), sending the combination of lower case letters or underscore, along with the parameter. The resulting object is then sent the deliver! method, which well... delivers it.</p></div>
<h3 id="_complete_list_of_actionmailer_user_settable_attributes">2.3. Complete List of ActionMailer user-settable attributes</h3>
<div class="tableblock">
<table rules="all"
@@ -330,7 +359,7 @@ http://www.gnu.org/software/src-highlite --> <span style="font-weight: bold"><span style="color: #0000FF">end</span></span></tt></pre></div></div>
<h3 id="_action_mailer_layouts">2.5. Action Mailer Layouts</h3>
-<div class="paragraph"><p>Just like controller views, you can also have mailer layouts. The layout needs end in _mailer to be automatically recognized by your mailer as a layout. So in our UserMailer example, we need to call our layout user_mailer.[html,txt].erb. In order to use a different file just use:</p></div>
+<div class="paragraph"><p>Just like controller views, you can also have mailer layouts. The layout name needs to end in _mailer to be automatically recognized by your mailer as a layout. So in our UserMailer example, we need to call our layout user_mailer.[html,txt].erb. In order to use a different file just use:</p></div>
<div class="listingblock">
<div class="content"><!-- Generator: GNU source-highlight 2.9
by Lorenzo Bettini
@@ -342,14 +371,170 @@ http://www.gnu.org/software/src-highlite --> <span style="font-weight: bold"><span style="color: #0000FF">end</span></span></tt></pre></div></div>
<div class="paragraph"><p>Just like with controller views, use yield to render the view inside the layout.</p></div>
-<h3 id="_sending_multipart_emails">2.6. Sending multipart emails</h3>
-<div class="paragraph"><p>Coming soon!</p></div>
+<h3 id="_generating_url_8217_s_in_action_mailer_views">2.6. Generating URL’s in Action Mailer views</h3>
+<div class="paragraph"><p>URLs can be generated in mailer views using url_for or named routes.
+Unlike controllers from Action Pack, the mailer instance doesn’t have any context about the incoming request, so you’ll need to provide all of the details needed to generate a URL.</p></div>
+<div class="paragraph"><p>When using url_for you’ll need to provide the :host, :controller, and :action:</p></div>
+<div class="literalblock">
+<div class="content">
+<pre><tt><%= url_for(:host => "example.com", :controller => "welcome", :action => "greeting") %></tt></pre>
+</div></div>
+<div class="paragraph"><p>When using named routes you only need to supply the :host:</p></div>
+<div class="literalblock">
+<div class="content">
+<pre><tt><%= users_url(:host => "example.com") %></tt></pre>
+</div></div>
+<div class="paragraph"><p>You will want to avoid using the name_of_route_path form of named routes because it doesn’t make sense to generate relative URLs in email messages. The reason that it doesn’t make sense is because the email is opened on a mail client outside of your environment. Since the email is not being served by your server, a URL like "/users/show/1", will have no context. In order for the email client to properly link to a URL on your server it needs something like "http://yourserver.com/users/show/1".</p></div>
+<div class="paragraph"><p>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:</p></div>
+<div class="literalblock">
+<div class="content">
+<pre><tt>ActionMailer::Base.default_url_options[:host] = "example.com"</tt></pre>
+</div></div>
+<div class="paragraph"><p>This can also be set as a configuration option in config/environment.rb:</p></div>
+<div class="literalblock">
+<div class="content">
+<pre><tt>config.action_mailer.default_url_options = { :host => "example.com" }</tt></pre>
+</div></div>
+<div class="paragraph"><p>If you do decide to set a default :host for your mailers you will want to use the :only_path => false 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 :host option isn’t explicitly provided.</p></div>
+<h3 id="_sending_multipart_emails">2.7. Sending multipart emails</h3>
+<div class="paragraph"><p>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.txt.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.</p></div>
+<div class="paragraph"><p>To explicitly specify multipart messages, you can do something like:</p></div>
+<div class="listingblock">
+<div class="content"><!-- Generator: GNU source-highlight 2.9
+by Lorenzo Bettini
+http://www.lorenzobettini.it
+http://www.gnu.org/software/src-highlite -->
+<pre><tt><span style="font-weight: bold"><span style="color: #0000FF">class</span></span> UserMailer <span style="color: #990000"><</span> ActionMailer<span style="color: #990000">::</span>Base
+
+ <span style="font-weight: bold"><span style="color: #0000FF">def</span></span> welcome_email<span style="color: #990000">(</span>user<span style="color: #990000">)</span>
+ recipients user<span style="color: #990000">.</span>email_address
+ subject <span style="color: #FF0000">"New account information"</span>
+ from <span style="color: #FF0000">"system@example.com"</span>
+ content_type <span style="color: #FF0000">"multipart/alternative"</span>
+
+ part <span style="color: #990000">:</span>content_type <span style="color: #990000">=></span> <span style="color: #FF0000">"text/html"</span><span style="color: #990000">,</span>
+ <span style="color: #990000">:</span>body <span style="color: #990000">=></span> <span style="color: #FF0000">"<p>html content, can also be the name of an action that you call<p>"</span>
+
+ part <span style="color: #FF0000">"text/plain"</span> <span style="font-weight: bold"><span style="color: #0000FF">do</span></span> <span style="color: #990000">|</span>p<span style="color: #990000">|</span>
+ p<span style="color: #990000">.</span>body <span style="color: #990000">=</span> <span style="color: #FF0000">"text content, can also be the name of an action that you call"</span>
+ <span style="font-weight: bold"><span style="color: #0000FF">end</span></span>
+ <span style="font-weight: bold"><span style="color: #0000FF">end</span></span>
+
+<span style="font-weight: bold"><span style="color: #0000FF">end</span></span></tt></pre></div></div>
+<h3 id="_sending_emails_with_attachments">2.8. Sending emails with attachments</h3>
+<div class="paragraph"><p>Attachments can be added by using the attachment method:</p></div>
+<div class="listingblock">
+<div class="content"><!-- Generator: GNU source-highlight 2.9
+by Lorenzo Bettini
+http://www.lorenzobettini.it
+http://www.gnu.org/software/src-highlite -->
+<pre><tt><span style="font-weight: bold"><span style="color: #0000FF">class</span></span> UserMailer <span style="color: #990000"><</span> ActionMailer<span style="color: #990000">::</span>Base
+
+ <span style="font-weight: bold"><span style="color: #0000FF">def</span></span> welcome_email<span style="color: #990000">(</span>user<span style="color: #990000">)</span>
+ recipients user<span style="color: #990000">.</span>email_address
+ subject <span style="color: #FF0000">"New account information"</span>
+ from <span style="color: #FF0000">"system@example.com"</span>
+ content_type <span style="color: #FF0000">"multipart/alternative"</span>
+
+ attachment <span style="color: #990000">:</span>content_type <span style="color: #990000">=></span> <span style="color: #FF0000">"image/jpeg"</span><span style="color: #990000">,</span>
+ <span style="color: #990000">:</span>body <span style="color: #990000">=></span> File<span style="color: #990000">.</span>read<span style="color: #990000">(</span><span style="color: #FF0000">"an-image.jpg"</span><span style="color: #990000">)</span>
+
+ attachment <span style="color: #FF0000">"application/pdf"</span> <span style="font-weight: bold"><span style="color: #0000FF">do</span></span> <span style="color: #990000">|</span>a<span style="color: #990000">|</span>
+ a<span style="color: #990000">.</span>body <span style="color: #990000">=</span> generate_your_pdf_here<span style="color: #990000">()</span>
+ <span style="font-weight: bold"><span style="color: #0000FF">end</span></span>
+ <span style="font-weight: bold"><span style="color: #0000FF">end</span></span>
+
+<span style="font-weight: bold"><span style="color: #0000FF">end</span></span></tt></pre></div></div>
</div>
<h2 id="_receiving_emails">3. Receiving Emails</h2>
<div class="sectionbody">
+<div class="paragraph"><p>Receiving and parsing emails with Action Mailer can be a rather complex endeavour. Before your email reaches your Rails app, you would have had to configure your system to somehow forward emails to your app, which needs to be listening for that.
+So, to receive emails in your Rails app you’ll need:</p></div>
+<div class="olist arabic"><ol class="arabic">
+<li>
+<p>
+Configure your email server to forward emails from the address(es) you would like your app to receive to /path/to/app/script/runner 'UserMailer.receive(STDIN.read)'
+</p>
+</li>
+<li>
+<p>
+Implement a receive method in your mailer
+</p>
+</li>
+</ol></div>
+<div class="paragraph"><p>Once a method called receive is defined in any mailer, Action Mailer will parse the raw incoming email into an email object, decode it, instantiate a new mailer, and pass the email object to the mailer object‘s receive method. Here’s an example:</p></div>
+<div class="listingblock">
+<div class="content"><!-- Generator: GNU source-highlight 2.9
+by Lorenzo Bettini
+http://www.lorenzobettini.it
+http://www.gnu.org/software/src-highlite -->
+<pre><tt><span style="font-weight: bold"><span style="color: #0000FF">class</span></span> UserMailer <span style="color: #990000"><</span> ActionMailer<span style="color: #990000">::</span>Base
+
+ <span style="font-weight: bold"><span style="color: #0000FF">def</span></span> receive<span style="color: #990000">(</span>email<span style="color: #990000">)</span>
+ page <span style="color: #990000">=</span> Page<span style="color: #990000">.</span>find_by_address<span style="color: #990000">(</span>email<span style="color: #990000">.</span>to<span style="color: #990000">.</span>first<span style="color: #990000">)</span>
+ page<span style="color: #990000">.</span>emails<span style="color: #990000">.</span>create<span style="color: #990000">(</span>
+ <span style="color: #990000">:</span>subject <span style="color: #990000">=></span> email<span style="color: #990000">.</span>subject<span style="color: #990000">,</span>
+ <span style="color: #990000">:</span>body <span style="color: #990000">=></span> email<span style="color: #990000">.</span>body
+ <span style="color: #990000">)</span>
+
+ <span style="font-weight: bold"><span style="color: #0000FF">if</span></span> email<span style="color: #990000">.</span>has_attachments?
+ <span style="font-weight: bold"><span style="color: #0000FF">for</span></span> attachment <span style="font-weight: bold"><span style="color: #0000FF">in</span></span> email<span style="color: #990000">.</span>attachments
+ page<span style="color: #990000">.</span>attachments<span style="color: #990000">.</span>create<span style="color: #990000">(</span><span style="color: #FF0000">{</span>
+ <span style="color: #990000">:</span>file <span style="color: #990000">=></span> attachment<span style="color: #990000">,</span>
+ <span style="color: #990000">:</span>description <span style="color: #990000">=></span> email<span style="color: #990000">.</span>subject
+ <span style="color: #FF0000">}</span><span style="color: #990000">)</span>
+ <span style="font-weight: bold"><span style="color: #0000FF">end</span></span>
+ <span style="font-weight: bold"><span style="color: #0000FF">end</span></span>
+ <span style="font-weight: bold"><span style="color: #0000FF">end</span></span>
+
+
+<span style="font-weight: bold"><span style="color: #0000FF">end</span></span></tt></pre></div></div>
</div>
<h2 id="_using_action_mailer_helpers">4. Using Action Mailer Helpers</h2>
<div class="sectionbody">
+<div class="paragraph"><p>Action Mailer classes have 4 helper methods available to them:</p></div>
+<div class="tableblock">
+<table rules="all"
+width="100%"
+frame="border"
+cellspacing="0" cellpadding="4">
+<col width="20%" />
+<col width="80%" />
+<tbody valign="top">
+<tr>
+<td align="left"><p class="table">add_template_helper(helper_module)</p></td>
+<td align="left"><p class="table">Makes all the (instance) methods in the helper module available to templates rendered through this controller.</p></td>
+</tr>
+<tr>
+<td align="left"><p class="table">helper(*args, &block)</p></td>
+<td align="left"><p class="table">Declare a helper:
+ helper :foo
+requires <em>foo_helper</em> and includes FooHelper in the template class.
+ helper FooHelper
+includes FooHelper in the template class.
+evaluates the block in the template class, adding method foo.
+ helper(:three, BlindHelper) { def mice() <em>mice</em> end }
+does all three.</p></td>
+</tr>
+<tr>
+<td align="left"><p class="table">helper_method</p></td>
+<td align="left"><p class="table">Declare a controller method as a helper. For example,
+ helper_method :link_to
+ def link_to(name, options) ... end
+makes the link_to controller method available in the view.</p></td>
+</tr>
+<tr>
+<td align="left"><p class="table">helper_attr</p></td>
+<td align="left"><p class="table">Declare a controller attribute as a helper. For example,
+ helper_attr :name
+ attr_accessor :name
+makes the name and name= controller methods available in the view.
+The is a convenience wrapper for helper_method.</p></td>
+</tr>
+</tbody>
+</table>
+</div>
</div>
<h2 id="_action_mailer_configuration">5. Action Mailer Configuration</h2>
<div class="sectionbody">
@@ -547,10 +732,6 @@ http://www.gnu.org/software/src-highlite --> <div class="sectionbody">
<div class="paragraph"><p>This guide presented how to create a mailer and how to test it. In reality, you may find that writing your tests before you actually write your code to be a rewarding experience. It may take some time to get used to TDD (Test Driven Development), but coding this way achieves two major benefits. Firstly, you know that the code does indeed work, because the tests fail (because there’s no code), then they pass, because the code that satisfies the tests was written. Secondly, when you start with the tests, you don’t have to make time AFTER you write the code, to write the tests, then never get around to it. The tests are already there and testing has now become part of your coding regimen.</p></div>
</div>
-<h2 id="_changelog">8. Changelog</h2>
-<div class="sectionbody">
-<div class="paragraph"><p><a href="http://rails.lighthouseapp.com/projects/16213/tickets/25">Lighthouse ticket</a></p></div>
-</div>
</div> </div> |