安排在rails中发送电子邮件

时间:2018-05-10 18:19:12

标签: ruby-on-rails ruby html-email

我需要在客户注册3个月后发送电子邮件,我正在使用gem交换程序,现在我在客户端注册时发送电子邮件,但我需要同时执行这两项操作。

1 个答案:

答案 0 :(得分:0)

你需要有某种宝石来做cron工作,比如whenever。或者只是使用常规的linux cron直接运行脚本,然后将其编程为每天运行。

然后检查用户何时注册的脚本:

User.where(sent_email: false).each do |user|
    if user.registered_date + 3.months < Time.now
        #send email
        user.update(sent_email:true)
    end
end
相关问题