Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7782611
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T19:35:47+00:00 2026-06-01T19:35:47+00:00

I am currently working on a project based on ruby on rails. A particular

  • 0

I am currently working on a project based on ruby on rails. A particular feature of the website involves sending timely notifications through mails which contained a summary all the posts posted on the website. The mail was sent at a default interval of 30 days. So each user received a mail on a different day based on the day of his registration and also the date of the last news letter sent which was one of the data associated with the user.

But now I am thinking of adding settings to newsletter so that a user can configure the interval on which he wants to get the newsletter. So instead of sending newsletter based on the date last news letter was sent, I would like to send the newsletter to all the users on particular days of the month.

For example if a user wished to receive a newsletter weekly it would be sent on every sunday of the week. for monthly the newsletter would be sent on 1st on every month and so on.

One approach that came to my mind is to create a base class for sending newsletters and then creating subclasses for monthly,weekly… and so on to utilize the object orientedness of ruby. But I am not sure if this is the best way to proceed with solving the problem.

I wanted to know if there are other ways this problem could be solved. I do not need a ruby on rails way of solving, anybody having experience with solving this problem in any other programming language may help.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-01T19:35:48+00:00Added an answer on June 1, 2026 at 7:35 pm

    This is a design issue, and it may come down to whether it becomes more cumbersome to break the scheduling behavior into multiple classes. You will avoid a case statement, which is an indication that polymorphism could have been used.

    If you do, however, choose to use separate classes, this is a good time for the ActiveRecord implementation of the type field. Each subscriber belongs to a schedule. (I’d recommend a schedule has one subscriber.)

    The schedules table would have a type field, with the name of the class. You don’t have to set the type. Instead, to store the schedule, create the schedule object using the association from the subscriber object, and ActiveRecord will set the type field.

    Now, whenever you get a schedule object from the database, it will be the class specified in the type field. You can have class for day of the week, a different one for date of the month, and as many different classes as different date calculation behaviors.

    Do store the next due email date. This should be in the schedules table, but you could put it in the subscribers table, if that’s more convenient.

    Use a method to calculate the next due date. Make sure that method has the same signature in all the classes. So, for the monthly schedule, store the date of the month in the table and do not pass the date of the month to the common method. That way the delivery code can call the method to update the due date, without having to know anything about the schedule algorithm or data.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm working on a ruby on rails project currently, doing it without scaffolding or
I am currently working on a multi branch desktop based project using VB.NET 2008.
I'm currently working on a project that is building a java-based desktop application to
I'm currently working on a Haskell project which automatically tests some functions based on
Currently working on a flex AIR project based on PureMVC framework. There was a
I am currently working on a project that is based on SPARQL and Protege
I'm currently working on a UIMA based project, and the data set I am
I'm currently working on a symfony2 based project with lots of ajax usage. Now
I'm currently working on large C++ Qt based project which is a about to
What I have so far: I'm currently working on a Lift-based project for work.

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.