How can I send an email to user at a specific time that he has set himself?
For example, he has decided that he wants to start a particular activity on 15th feb. Now I want to send him a mail one day before 15th feb.
Currently this is what I have thought of but this checks everyday if there is any such user whose activity starts in one day. Is there a way that eliminates the checks and instead does a triggering?
scheduler.cron("0 5 * * *") do UserActivity.all.each do |user_activity| if (Time.now - user_activity.start_time )/1.day < 1 ChallengeNotifier.send_challenge_start_notifier(user_activity.user).deliver end end end