0
我需要发送大量电子邮件,我将使用拖后作业延迟作业,并且必须以3种语言(de,en,re)创建电子邮件,我怎样才能缓存视图,以便每次调用邮件方法时都不必创建该视图。如何在发送大量电子邮件时缓存邮件视图
我需要发送大量电子邮件,我将使用拖后作业延迟作业,并且必须以3种语言(de,en,re)创建电子邮件,我怎样才能缓存视图,以便每次调用邮件方法时都不必创建该视图。如何在发送大量电子邮件时缓存邮件视图
的实现方法是发送电子邮件的人,所以你可以这样做:
def send_emails
# You can set here the email with attachments and all stuff
mail = MyMailer.send_message("[email protected]")
body = mail.html_part.body
User.all.each do |u|
mail.to = u.email
mail.html_part.body = body.gsub(/user_id/, u.id)
mail.deliver
end
end
当然是更好,如果你设置了后台处理此方法。
如果它比可能更好使用'find_each'而不是'all'更重要? – 2013-11-26 19:00:46