Search code examples
ruby-on-railsice-cube

RoR repeated events


I have:

scaffold EventGroup name:string description:text event_quantity:integer
scaffold Event event_name:string starts_at:datetime ends_at:datetime event_group:references

Dependencies:

EventGroup has_many: events
Event belongs_to: event_group

How can I schedule repeating events for event_group [every friday and sunday, 4 times]? Any ideas?...


Solution

  • iCalendar provides standards for capturing event repeat rules (see here). There are many examples, including one similar to yours:

    Weekly on Tuesday and Thursday for 5 weeks:

    DTSTART;TZID=US-Eastern:19970902T090000 RRULE:FREQ=WEEKLY;UNTIL=19971007T000000Z;WKST=SU;BYDAY=TU,TH

    or

    RRULE:FREQ=WEEKLY;COUNT=10;WKST=SU;BYDAY=TU,TH

    That's just for capturing the rule. How you capture it (what your UI looks like) and how you use it are entirely different topics.

    When you say, "How can I schedule repeating events", that sounds like a much broader question.