我需要按照管理员指定的时间表发送邮件。管理员可以指定两天内发送邮件。在公司活动结束前的几天通过管理界面指定的日子。按时间表发送电子邮件
我会用DelayedJob
这个。
class Email < ActiveRecord::Base
belongs_to :campaign
end
class CreateEmails < ActiveRecord::Migration
def change
create_table :emails do |t|
t.integer :days1
t.integer :days2
t.timestamps
end
end
end
class Campaign < ActiveRecord::Base
has_many :emails
def end_time
created_at + ends_at.day
end
end
方法end_time
决定何时完成公司的活动。
ends_at
此字段从数据库中填写管理员创建公司。
我的自动化替代我不确定你在问什么。你不确定如何使用'DelayedJob'? [你有什么尝试?](http://whathaveyoutried.com) – lime
你为什么要使用延迟工作?为了安排? –
@JohnNaegle还有哪些其他的选择?我更喜欢DJ。 – user3458697