0

I am attempting to use the ice_cube gem to set up a schedule for recurring shifts. What I am struggling with is the recurring events are not real instances of my model with an ID; I need to be able to reference each event to associate it with a shift_confirmation method (detailing things like the actual end time vs. the booked end time, whether the shift has been paid, etc.).

Where I'm struggling is that if I add an actual instance of my model, as opposed to a recurring instance, I will end up with both - the instance I can refer to with an ID, and also a recurring instance.

I have considered whether I can add an IceCube exception that removes a shift from the recurrence schedule each time a user wants to edit it (e.g. to mark it complete, paid, etc.), and create an instance of my model, but this seems very unclean - there must be a better way.

Is there any way to refer definitively to an specific event in an ice_cube recurring schedule, so that I can do things like mark it paid (which would be in an associated model)?

Harry
  • 4,660
  • 7
  • 37
  • 65
  • You're going to have to clarify what you're doing by laying out your entities and their relationships in more detail. You keep using the term "my model" without indicating the actual model to which you're referring. Do you mean Shift? Even just clearly defining Shift vs RecurringInstance or whatever else you're working with would go miles into making your issue understandable. – MarsAtomic Aug 19 '15 at 20:40

2 Answers2

0

When you create an schedule, the schedule has an idea, probably you can use this in your structure.

I viewed this post, because i've a similar problem.

I've an table activities, with start-, end datum and duration and an related table schedule with the reference 'activity_id'. I didn't want to store the ice-cube to_yaml string, because I want the option to add 'closing dates' in the future on a central place, without parsing every record again.

If you show your structure, maybe I can be of some help.

Regards, sander

0

Check out the schedulable gem, it lets you persist event_occurrences in the database and let's your "schedule" edit only future occurrences.

Yshmarov
  • 3,450
  • 1
  • 22
  • 41