Skip to content

Commit

Permalink
Merge pull request #37461 from code-dot-org/fix-destroy-error
Browse files Browse the repository at this point in the history
Pass IDs rather than objects to `.destroy`
  • Loading branch information
Hamms committed Oct 26, 2020
2 parents d068f14 + 25c5942 commit c9a5d81
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion dashboard/lib/services/script_seed.rb
Original file line number Diff line number Diff line change
Expand Up @@ -235,7 +235,7 @@ def self.import_levels_script_levels(levels_script_levels_data, seed_context)
def self.destroy_outdated_objects(model_class, all_objects, imported_objects, seed_context)
objects_to_keep_by_seeding_key = imported_objects.index_by {|o| o.seeding_key(seed_context)}
should_keep = all_objects.group_by {|o| objects_to_keep_by_seeding_key.include?(o.seeding_key(seed_context))}
model_class.destroy(should_keep[false]) if should_keep.include?(false)
model_class.destroy(should_keep[false].pluck(:id)) if should_keep.include?(false)
should_keep[true]
end

Expand Down

0 comments on commit c9a5d81

Please sign in to comment.