aboutsummaryrefslogtreecommitdiffstats
path: root/guides
diff options
context:
space:
mode:
authorRyuta Kamizono <kamipo@gmail.com>2018-03-22 06:52:33 +0900
committerRyuta Kamizono <kamipo@gmail.com>2018-03-22 07:07:33 +0900
commit4c9c3ffc2e80155f31dbcf80591618ed1c858685 (patch)
tree9df4ad5881249e4572b216f21c5a08b955322a2e /guides
parent242ae67ebe98685464b8f23f527e2102dfc3df88 (diff)
parentbc32fa66ee0ebf1be57adb6adae183e61291eed5 (diff)
downloadrails-4c9c3ffc2e80155f31dbcf80591618ed1c858685.tar.gz
rails-4c9c3ffc2e80155f31dbcf80591618ed1c858685.tar.bz2
rails-4c9c3ffc2e80155f31dbcf80591618ed1c858685.zip
Merge pull request #31869 from BKSpurgeon/patch-1
[ci skip] Update Action Mailer Documentation
Diffstat (limited to 'guides')
-rw-r--r--guides/source/action_mailer_basics.md28
1 files changed, 16 insertions, 12 deletions
diff --git a/guides/source/action_mailer_basics.md b/guides/source/action_mailer_basics.md
index 9f239da90f..662f9ea38a 100644
--- a/guides/source/action_mailer_basics.md
+++ b/guides/source/action_mailer_basics.md
@@ -20,9 +20,18 @@ Introduction
------------
Action Mailer allows you to send emails from your application using mailer classes
-and views. Mailers work very similarly to controllers. They inherit from
-`ActionMailer::Base` and live in `app/mailers`, and they have associated views
-that appear in `app/views`.
+and views.
+
+#### Mailers are similar to controllers
+
+They inherit from `ActionMailer::Base` and live in `app/mailers`. Mailers also work
+very similarly to controllers. Some examples of similarities are enumerated below.
+Mailers have:
+
+* Actions, and also, associated views that appear in `app/views`.
+* Instance variables that are accessible in views.
+* The ability to utilise layouts and partials.
+* The ability to access a params hash.
Sending Emails
--------------
@@ -60,8 +69,7 @@ end
```
As you can see, you can generate mailers just like you use other generators with
-Rails. Mailers are conceptually similar to controllers, and so we get a mailer,
-a directory for views, and a test.
+Rails.
If you didn't want to use a generator, you could create your own file inside of
`app/mailers`, just make sure that it inherits from `ActionMailer::Base`:
@@ -73,10 +81,9 @@ end
#### Edit the Mailer
-Mailers are very similar to Rails controllers. They also have methods called
-"actions" and use views to structure the content. Where a controller generates
-content like HTML to send back to the client, a Mailer creates a message to be
-delivered via email.
+Mailers have methods called "actions" and they use views to structure their content.
+Where a controller generates content like HTML to send back to the client, a Mailer
+creates a message to be delivered via email.
`app/mailers/user_mailer.rb` contains an empty mailer:
@@ -110,9 +117,6 @@ messages in this class. This can be overridden on a per-email basis.
* `mail` - The actual email message, we are passing the `:to` and `:subject`
headers in.
-Just like controllers, any instance variables we define in the method become
-available for use in the views.
-
#### Create a Mailer View
Create a file called `welcome_email.html.erb` in `app/views/user_mailer/`. This