This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def create | |
@room = Room.find(params[:room_id]) | |
@event = @room.events.create(event_params) | |
@event.create_recurring_events | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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