views:

25

answers:

1

Using Ruby on Rails 2.3.8, I'm wondering how to represent a schedule for model that handles "reminders".

Examples of reminder:
"Must do ABC", Remind me in 3 days
"Must do DEF", Remind me in 5 weeks
"Must do XYZ", Remind me on 2nd Oct 2010 at 5 pm

So, the Must do... goes into a description column.

But how to deal with the fact that when to remind can have different types of values?
Some things I thought of:

  1. I was thinking of creating a column for each type (remind_in_days, remind_in_weeks, remind_at)
    -->But this feels a bit kludgy.

  2. Have a field called remind_type which will be used to determine the type of value stored in a field called remind_type_value
    -->If I use this approach, is there a way that I can simply say in Rails code something like Reminder.RemindValue without having to use code like if remind_type==x then x?

  3. ?

Any ideas of how I should proceed (in a manner that is possibly elegant)?

+1  A: 

Why not just hard code times from now when when saving? "Remind me in two weeks" when saving could just do something like, reminder.remind_at = 2.weeks.from_now.

Matt Briggs