This is more of a macro type question, I am looking for plugin/how to go about advice. I have users who have different subscription attributes, some might have monday, wednesday, saturday... some might have every day of the week. I need to set up a mailer that will send out a specific template at 5:00am every day to every user that has a subscription for that day. So if a user is subscribed to monday, 开发者_开发知识库that user and every other user with the monday subscription attribute gets the email. Does anyone have advice in terms of what plugin might work best for me in terms of automating sending mail based on the day of the week?
Thank you!
One approach you might consider would be to create a custom Rake task because Rake has access to your Rails' models. This task would be invoked by a cron job, so for example, at 05:00 every day the Rake task would fire and get all the users subscribed to that day and generate the emails. You'd almost certainly want to send the emails out asynchronously using something like Delayed Job.
Give a look at Delayed Job or whenever.
Well, what you're really looking for is a scheduler. My favorite one is rufus-scheduler. It runs from within Rails, doesn't require a separate instance, accepts many different types of schedulings (cron-like and human-like) ... It's quite cool. You can set it to run a query every day for users with that day's subscription and email them.
精彩评论