Rufus-时区调度程序变量 - ruby on Rails
我正在运行一个 Rails 应用程序,它使用 rufus-scheduler 在中午向所有用户发送每日电子邮件,但是,它目前在中午向应用程序时区“台北”发送电子邮件。
我在注册时捕获用户时区,但我无法将变量放入 rufus-scheduler 任务中,
scheduler.cron('0 15 * * * @time_zone') do
Account.all.each do |account|
CODE
account.users.each do |user|
DELIVER EMAIL CODE
end
end
end
我想我只是不确定在哪里定义 @time_zone 变量,以便 rufus 能够正确读取它。
提前致谢!
I am running a rails app that uses rufus-scheduler to send out a daily e-mail to all users at noon, however, it currently sends it out at noon for the apps timezone "Taipei".
I am capturing user timezones on signup, but I am unable to put a variable into a rufus-scheduler task
scheduler.cron('0 15 * * * @time_zone') do
Account.all.each do |account|
CODE
account.users.each do |user|
DELIVER EMAIL CODE
end
end
end
I guess I'm just not sure where to define the @time_zone variable so that rufus will read it properly.
Thanks in advance!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
调度程序不需要关心时区,最好以 UTC 来考虑。您想要做的是每小时运行一次任务,并仅查找当前午夜的帐户。所以你的代码看起来更像是这样的:
The scheduler doesn't need to care about timezones, it is better off thinking in UTC. What you want to do is run your task every hour and look for only those accounts where it is currently midnight. So your code would look more like this:
rufus-scheduler README 说
and the rufus-scheduler README says