I only want to send a reminder email to an applicant if their application is still in draft 30 days from when they start it. I can't find in the documentation a clear answer for this - does the delay on the job mean the entire method is delayed for 30 days, or the execution of it (the sending) is delayed? What I'd like to do is something like this (maybe not perfect code but you get the idea):
class EmailReminder
def initialize(application)
@application = application
end
def deliver
if @application.submitted_date.nil?
RemindApplicantMailer.deliver_now
end
end
handle_asynchronously :deliver, :run_at => Proc.new { 30.days.from_now }
end
# applications controller
def create
# create @application
reminder = EmailReminder.new(@application)
reminder.deliver
end
But I can't quite figure out if this would check the submitted date at the time it's called and then delay mail delivery, or if it would successfully wait 30 days before running the method and only deliver if conditions are met. Possibly better to use cron instead.. Thanks for any insight.
-Rachel