aboutsummaryrefslogtreecommitdiffstats
path: root/guides
diff options
context:
space:
mode:
authorRyuta Kamizono <kamipo@gmail.com>2018-08-17 12:41:35 +0900
committerRyuta Kamizono <kamipo@gmail.com>2018-08-17 12:43:09 +0900
commit6563a73e8967ce73f23e54969b6108a518bc694b (patch)
treeb99dd5c3e11d572275eae64c32ea239fee86a749 /guides
parent959bf6c8d32cd2296297e4927ba0e08631881654 (diff)
parent16acf4f9c759896fe180dec4eb75d88cebf7a7c5 (diff)
downloadrails-6563a73e8967ce73f23e54969b6108a518bc694b.tar.gz
rails-6563a73e8967ce73f23e54969b6108a518bc694b.tar.bz2
rails-6563a73e8967ce73f23e54969b6108a518bc694b.zip
Merge pull request #33537 from ZASMan/update_action_mailer_docs_custom_view_paths
Add note for custom mailer view paths in action mailer guide. [ci skip]
Diffstat (limited to 'guides')
-rw-r--r--guides/source/action_mailer_basics.md15
1 files changed, 15 insertions, 0 deletions
diff --git a/guides/source/action_mailer_basics.md b/guides/source/action_mailer_basics.md
index 6c5f03ab38..37cbf3f53d 100644
--- a/guides/source/action_mailer_basics.md
+++ b/guides/source/action_mailer_basics.md
@@ -422,6 +422,21 @@ 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.