views:

36

answers:

1

Is it possible to set template_root for ActionMailer at runtime? I seem to be able to do this in development mode by using:

ActionMailer::Base.template_root = my_view_path if File.exists (File.join(my_view_path,"test_mailer"))

I'm checking to see if the mailer views directory exists in my special view_path, and using that view_path for ActionMailer if it exists. Otherwise leave it default. This is happening at request time, not at config time in environment.rb. Works in development mode.

When I move this to my production server, I get an error at runtime that it cannot find the xxx.erb file in apps/views. So it is still looking in the default path instead of my special view path. I'm logging debug statements and can see that the template_root has been set correctly, but it seems the app is not using it.

Any ideas?

A: 

See http://www.quirkey.com/blog/2008/08/28/actionmailer-hacking-multiple-template-paths/ and my comment there. I know this is an old question, but I was stuck for days with it. Hope this will help someone.

Sorrow