QUick fix- more investigation needed
parent
fad467530c
commit
8dc1be228b
|
@ -83,6 +83,9 @@ module Api
|
|||
|
||||
def clean_expired_farm_events
|
||||
FarmEvents::CleanExpired.run!(device: current_device)
|
||||
# TODO: Why does this even exist? This should
|
||||
# be fixable via foreign key constraints. - RC 4 OCT 19
|
||||
Fragment.remove_old_fragments_for_device(current_device)
|
||||
end
|
||||
|
||||
# Rails 5 params are no longer simple hashes. This was for security reasons.
|
||||
|
|
|
@ -87,4 +87,8 @@ class Fragment < ApplicationRecord
|
|||
def broadcast?
|
||||
false
|
||||
end
|
||||
|
||||
def self.remove_old_fragments_for_device(dev)
|
||||
dev.fragments.select { |x| x.owner == nil }.map { |x| x.destroy! }
|
||||
end
|
||||
end
|
||||
|
|
|
@ -9,6 +9,7 @@ module PointGroups
|
|||
end
|
||||
|
||||
def validate
|
||||
Fragment.remove_old_fragments_for_device(device)
|
||||
add_error "in_use", :in_use, human_readable_error if in_use?
|
||||
end
|
||||
|
||||
|
@ -53,6 +54,7 @@ module PointGroups
|
|||
@fragment_users = Fragment
|
||||
.find(relevant_fragments)
|
||||
.map(&:owner)
|
||||
.compact # Referential integrity issues??? - RC 4 oct 19
|
||||
.map { |x| "#{x.class} '#{x.fancy_name}'" }
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Reference in New Issue