ActionMailer does not find templates in production mode

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:innotify_observers’
/usr/lib/ruby/1.8/observer.rb:184:in each' /usr/lib/ruby/1.8/observer.rb:184:innotify_observers’
(eval):10:in create_or_update_without_callbacks' app/controllers/event_controller.rb:71:inrequest_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

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:innotify_observers’
(eval):10:in create_or_update_without_callbacks' app/controllers/event_controller.rb:71:inrequest_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

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs