So I’m trying to figure out how to do this cleanly. Trying to keep the example simple lets say I have an object, MyMailMeeting in which I define two times that I want to send two different emails to people in a meeting.
In my MyMailMeeting model, I want to define both methods (rather than having their own delayed job class), but I need to have those methods see the times defined within the object in order to know when to send.
def send_first
... do stuff
end
handle_asynchronously :send_first, :run_at => Proc.new { send_first_time }
Problem is that according to the documentation, send_first_time needs to be a class method, and want it to be an instance method so that I can see the times defined by the user.
How do I do this? Or do I just need to create two separate Delayed_job classes and do something like this:
Delayed::Job.enqueue(SendFirstJob.new, :run_at => send_first_time)
I ended up using the second method. Though it isn’t as time sensitive as I would like.
If anyone has an answer on how to get
send_first_timeto be a variable that is based on user input, I’ll gladly accept it as the right answer. Thanks.