Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 19 additions & 12 deletions lib/schedulable/acts_as_schedulable.rb
Original file line number Diff line number Diff line change
Expand Up @@ -141,20 +141,27 @@ def acts_as_schedulable(name, options = {})
else
existing_records = []
end

if existing_records.any?
# Overwrite existing records
existing_records.each do |existing_record|
if !occurrences_records.update(existing_record.id, date: occurrence.to_datetime)
puts 'An error occurred while saving an existing occurrence record'

begin
if existing_records.any?
# Overwrite existing records
existing_records.each do |existing_record|
if !occurrences_records.update(existing_record.id, date: occurrence.to_datetime)
puts 'An error occurred while saving an existing occurrence record'
end
end
else
# Create new record
if !occurrences_records.create(date: occurrence.to_datetime)
puts 'An error occurred while creating an occurrence record'
end
end
else
# Create new record
if !occurrences_records.create(date: occurrence.to_datetime)
puts 'An error occurred while creating an occurrence record'
end
end
rescue ActiveRecord::RecordNotUnique, ActiveRecord::RecordNotFound => ex
# Ignore it
# next
rescue Exception => ex
raise ex
end
end


Expand Down