app/models/apidae/selection.rb in apidae-0.9.1 vs app/models/apidae/selection.rb in apidae-0.9.2
- old
+ new
@@ -27,10 +27,14 @@
added = imported_objs - current_objs
removed = current_objs - imported_objs
added.each do |o|
obj = Obj.find_by_apidae_id(o)
- SelectionObject.create(apidae_selection_id: apidae_sel.id, apidae_object_id: obj.id)
+ if obj
+ SelectionObject.create(apidae_selection_id: apidae_sel.id, apidae_object_id: obj.id)
+ else
+ logger.error "Object #{o} referenced in selection #{apidae_sel.apidae_id} and project #{apidae_proj_id} is unknown"
+ end
end
removed_ids = Obj.where(apidae_id: removed).map {|o| o.id}
SelectionObject.where(apidae_selection_id: apidae_sel.id, apidae_object_id: removed_ids).delete_all
end