I’m looking forward to allowing my users configure their email notifications frequency.
I’d like to offer them the typical options: direct email, daily and weekly digests
¿What would it be the best strategy to build this within a rails 3 application?
Thanks all !
You could have an
email_frequency_preferencestring column on youruserstable that stores their preference. Then you can find users by their email frequency preference:I also suggest having an
Eventmodel, with name and description, to represent events that may happen that you want to notify your users of. Then you can find events by their creation date:Now, you have to handle all three frequency preferences separately:
Whenever an event happens, find all users who prefer instant event email notifications and send it to them immediately.
At the end of every week, find all events that happened that week:
Combine their descriptions into a single email, then find all users who prefer weekly event email notifications and send it to them.
At the end of every month, find all events that during happened that month:
Combine their descriptions into a single email, then find all users who prefer monthly event email notifications and send it to them.