aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorZane <i.zane.am.robot@gmail.com>2018-08-06 11:58:58 -0400
committerZane <i.zane.am.robot@gmail.com>2018-08-16 21:37:08 -0400
commit16acf4f9c759896fe180dec4eb75d88cebf7a7c5 (patch)
tree92f998707c864592de9b96eb4ffc526c756dbaf9
parenta6e86dd2a86a89b7775e27a2f0e728cb6afd1513 (diff)
downloadrails-16acf4f9c759896fe180dec4eb75d88cebf7a7c5.tar.gz
rails-16acf4f9c759896fe180dec4eb75d88cebf7a7c5.tar.bz2
rails-16acf4f9c759896fe180dec4eb75d88cebf7a7c5.zip
Add note for custom mailer view paths in action mailer guide. [ci skip]
Adds stuff Fixes a typo Integrates changes Adds link to append_view_path in actionmailer guide.
-rw-r--r--guides/source/action_mailer_basics.md16
1 files changed, 16 insertions, 0 deletions
diff --git a/guides/source/action_mailer_basics.md b/guides/source/action_mailer_basics.md
index 6c5f03ab38..2bc8fb1baf 100644
--- a/guides/source/action_mailer_basics.md
+++ b/guides/source/action_mailer_basics.md
@@ -422,6 +422,22 @@ 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
`:text`, `:inline` etc.
+If you would like to render a template located outside of the default `app/views/mailer_name/` directory, you can apply the `prepend_view_path`, like so:
+
+```ruby
+class UserMailer < ApplicationMailer
+ prepend_view_path "custom/path/to/mailer/view"
+
+ # This will try to load "custom/path/to/mailer/view/welcome_email" template
+ def welcome_email
+ # ...
+ end
+end
+
+```
+
+You can also consider using the [append_view_path](https://guides.rubyonrails.org/action_view_overview.html#view-paths) method.
+
#### Caching mailer view
You can perform fragment caching in mailer views like in application views using the `cache` method.