diff --git a/app/controllers/assays_controller.rb b/app/controllers/assays_controller.rb index 796642c82d..dab907ae86 100644 --- a/app/controllers/assays_controller.rb +++ b/app/controllers/assays_controller.rb @@ -114,6 +114,7 @@ def create def delete_linked_sample_types return unless is_single_page_assay? + return if @assay.sample_type.nil? @assay.sample_type.destroy end diff --git a/app/controllers/studies_controller.rb b/app/controllers/studies_controller.rb index bec5ef69fc..c5600c64e2 100644 --- a/app/controllers/studies_controller.rb +++ b/app/controllers/studies_controller.rb @@ -91,6 +91,7 @@ def update def delete_linked_sample_types return unless is_single_page_study? + return if @study.sample_types.empty? # The study sample types must be destroyed in reversed order # otherwise the first sample type won't be removed becaused it is linked from the second