在我的mailers / event_mailer类中,我有几个方法。每种方法都是:
而不是重复步骤1& 2对于每个方法,有没有办法在event_mailer类的“构造函数”中初始化一次?
注册控制器代码:
EventMailer.notify_admins(@user,subject,topic).deliver
event_mailer.rb代码:
class EventMailer < ActionMailer::Base
@@smtp_settings = {
..........
}
def notify_admins(user,subject,topic)
@user = user
@topic = topic
......
mail(:from => 'test@example.com', :to => 'someone@someone.com', :subject => subject)
end
def notify_accounts(user,subject,topic)
@user = user
@topic = topic
......
mail(:from => 'test@example.com', :to => 'someone@someone.com', :subject => subject)
end