开发者

Setting ActionMailer template_root at runtime

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 req开发者_JAVA百科uest 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?


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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜