Skip to content

Instantly share code, notes, and snippets.

@excid3
Created March 20, 2017 19:17
Embed
What would you like to do?
def create
@room = Room.find(params[:room_id])
@event = @room.events.create(event_params)
@event.create_recurring_events
end
class Event
attribute :recurring, :boolean
def create_recurring_events
return unless recurring?
schedule.occurrences(end_time).each do |time|
# use the current event's attributes to populate the new one,
# but override the start time with the one from the schedule
room.events.create(attributes.merge(start_time: time))
end
end
def schedule
# your ice_cube schedule
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment