在 RoR 的活动前 2 天发布预定电子邮件的最佳方法是什么。活动日期将被存储到数据库中,我只想在活动前 2 天发出提醒。
问问题
185 次
2 回答
0
You might have figured this alreay out by yourself. Well...anyway: In cases as the described I always use an external crontab job. In a certain interval (in your case e.g. each day) you dial into your application via
rails runner script.rb
or
rails runner -e class-method
The script or the method then scans the db for pending trigger dates and does whatever it should do, e.g. sending emails.
ps: Of course you have to take care of the correct environment for your rails calls.
于 2012-09-12T08:54:15.640 回答
0
你可以试试这个
在您的 schedule.rb 文件中
every 1.day do
trigger mailer
end
并在邮件方法中
def mail_setup
if Date.today == event_date - 2.days
mail setup
else
do nothing
end
end
于 2012-07-17T14:07:08.897 回答