diff --git a/app/controllers/admin/categories_controller.rb b/app/controllers/admin/categories_controller.rb index df6fd128c..8d52212bb 100644 --- a/app/controllers/admin/categories_controller.rb +++ b/app/controllers/admin/categories_controller.rb @@ -52,7 +52,7 @@ def update start = Time.now begin category = LinkedData::Client::Models::Category.find_by_acronym(params[:id], include: ATTRIBUTE_TO_INCLUDE ).first - add_ontologies_to_object(category_params[:ontologies],category) if (category_params[:ontologies].size > 0 && category_params[:ontologies].first != '') + add_ontologies_to_object(category_params[:ontologies],category) if (category_params[:ontologies].present? && category_params[:ontologies].size > 0 && category_params[:ontologies].first != '') delete_ontologies_from_object(category_params[:ontologies],category.ontologies,category) category.update_from_params(category_params) category_update = category.update diff --git a/app/controllers/admin/groups_controller.rb b/app/controllers/admin/groups_controller.rb index 17bc12511..3df27d2e0 100644 --- a/app/controllers/admin/groups_controller.rb +++ b/app/controllers/admin/groups_controller.rb @@ -52,7 +52,7 @@ def update start = Time.now begin group = LinkedData::Client::Models::Group.find_by_acronym(params[:id]).first - add_ontologies_to_object(group_params[:ontologies],group) if (group_params[:ontologies].size > 0 && group_params[:ontologies].first != '') + add_ontologies_to_object(group_params[:ontologies],group) if (group_params[:ontologies].present? && group_params[:ontologies].size > 0 && group_params[:ontologies].first != '') delete_ontologies_from_object(group_params[:ontologies],group.ontologies,group) group.update_from_params(group_params) group_updated = group.update diff --git a/app/controllers/concerns/submission_updater.rb b/app/controllers/concerns/submission_updater.rb index d283b82c0..85fe4306d 100644 --- a/app/controllers/concerns/submission_updater.rb +++ b/app/controllers/concerns/submission_updater.rb @@ -48,6 +48,7 @@ def add_ontologies_to_object(ontologies,object) end def delete_ontologies_from_object(new_ontologies,old_ontologies,object) + new_ontologies = [] if new_ontologies.nil? ontologies = old_ontologies - new_ontologies ontologies.each do |ont| ontology = LinkedData::Client::Models::Ontology.find(ont)