2012-04-03 67 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

相關問題