2012-04-03 61 views

回答

1

的实现方法是发送电子邮件的人,所以你可以这样做:

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 

当然是更好,如果你设置了后台处理此方法。

+0

如果它比可能更好使用'find_each'而不是'all'更重要? – 2013-11-26 19:00:46