# ActionMailer does not find templates in production mode

**URL:** <https://www.ruby-forum.com/t/actionmailer-does-not-find-templates-in-production-mode/182213>\
**Category:** Rails\
**Created:** [January 25, 2010, 9:20am UTC](https://www.ruby-forum.com/t/actionmailer-does-not-find-templates-in-production-mode/182213 "2010-01-25T09:20:42Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Thilo-Alexander\_Gin](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/t/3e96dc/32.png) [@Thilo-Alexander\_Gin](https://www.ruby-forum.com/u/Thilo-Alexander_Gin)\
**Post date:** [January 25, 2010, 9:20am UTC](https://www.ruby-forum.com/t/actionmailer-does-not-find-templates-in-production-mode/182213/1 "2010-01-25T09:20:42Z")

</div>

Hello everyone,

I am currently struggling with the following issue that only seems to  
appear  
in my production environment:

When attempting to send a mail from an ActionMailer the template  
location  
algorithm does not seem to pick up the corresponding template:

ActionView::MissingTemplate (Missing template  
event\_mailer/approval\_requested\_notification.erb in view path  
app/views):  
app/models/event\_observer.rb:3:in `after_enter_awaiting_approval' /usr/lib/ruby/1.8/observer.rb:185:in`notify\_observers’  
/usr/lib/ruby/1.8/observer.rb:184:in `each' /usr/lib/ruby/1.8/observer.rb:184:in`notify\_observers’  
(eval):10:in `create_or_update_without_callbacks' app/controllers/event_controller.rb:71:in`request\_approval’  
public/dispatch.fcgi:24

However, I do have a corresponding template named  
“approval\_requested\_notification.text.plain.erb” in  
“app/views/event\_mailer”,  
which is correctly picked up in development mode. In production mode,  
however,  
the content type infix is omitted while searching for the template.

This happens with Rails 2.3.4. Any suggestions how to sort this out are  
much  
appreciated!

Thanks,  
Thilo

---

<div class="post-metadata">

**Author:** ![Thilo-Alexander\_Gin](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/t/3e96dc/32.png) [@Thilo-Alexander\_Gin](https://www.ruby-forum.com/u/Thilo-Alexander_Gin)\
**Post date:** [January 25, 2010, 10:58pm UTC](https://www.ruby-forum.com/t/actionmailer-does-not-find-templates-in-production-mode/182213/2 "2010-01-25T22:58:35Z")

</div>

On Monday 25 January 2010 03:00:08 Thilo-Alexander Ginkel wrote:

> /usr/lib/ruby/1.8/observer.rb:184:in `each' /usr/lib/ruby/1.8/observer.rb:184:in`notify\_observers’  
> (eval):10:in `create_or_update_without_callbacks' app/controllers/event_controller.rb:71:in`request\_approval’  
> public/dispatch.fcgi:24

turns out that the issue is related to the fact that mod\_fcgi (used in  
production) sets a different working directory than WEBRick (used in  
development). The following code in environment.rb can be used as a  
workaround:

# work around a mod\_fcgi / ActionMailer bug

Dir.chdir(File.dirname( **FILE** ) \<\< ‘/…/’)

Regards,  
Thilo
