分隔目录中的 Rails 邮件程序视图 [英] Rails mailer views in separated directory
问题描述
我有一个小的组织问题,在我的应用程序中,我有 3 个邮件程序 User_mailer、prduct_mailer、some_other_mailer,它们都将视图存储在 app/views/user_mailer ...
I have small organizatoric issue, in my application I have 3 mailer User_mailer, prduct_mailer, some_other_mailer and all of them store their views in app/views/user_mailer ...
我希望在/app/views/中有一个名为 mailers 的子目录,并将所有内容放在文件夹 user_mailer、product_mailer 和 some_other_mailer 中.
I will want to have a subdirectory in /app/views/ called mailers and put all in the folders user_mailer, product_mailer and some_other_mailer.
谢谢,
推荐答案
我非常同意这个组织策略!
I so agree with this organization strategy!
从大雄的例子中,我通过以下方式实现了:
And from Nobita's example, I achieved it by doing:
class UserMailer < ActionMailer::Base
default :from => "whatever@whatever.com"
default :template_path => '**your_path**'
def whatever_email(user)
@user = user
@url = "http://whatever.com"
mail(:to => user.email,
:subject => "Welcome to Whatever",
)
end
end
这是 Mailer 特有的,但还不错!
It is Mailer-specific but not too bad!
这篇关于分隔目录中的 Rails 邮件程序视图的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!