Reputation: 93
I need to send mail on a schedule specified by the admin. Admin can specify two days in which is sending mail. The days which are specified through the admin interface, it days before the termination of activity of the company.
I would use DelayedJob
for this.
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
Method end_time
determines when you are finished with the activity of the company.
ends_at
this field from the database to fill the admin at creation of the company.
Upvotes: 0
Views: 97