Is it possible to customize the template path for Rails 3.1 ActionMailers? By default, Rails looks in:
/app/views/[mailer_class]
for the mailer view templates. However, I'd much rather organize them in:
/app/mailers/views/[mailer_class]
or at least:
/app/views/mailers/[mailer_class]
I know this was possible in 2.3 via ActionMailer's template_path
config parameter, but that seems to be deprecated as of Rails 3. Is this kind of customization no longer possible?
This sort of customization is possible still. There is a couple different ways to do this depending on how your mailers are written.
If you have the format blocks such as format.html you can pass render '/path/to/template'.
Or if you are just calling mail() there are two options for setting the path and template name, which you should just need to pass the path option:
mail(:template_path => 'mailers/[mailer_class]', :template_name => '[mailer_method]')
You should check out the Rails Guides for more detailed info.
http://guides.rubyonrails.org/action_mailer_basics.html#mailer-views
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With