From d9674e439cc52e55ba94fab15de3b561bd1969d7 Mon Sep 17 00:00:00 2001 From: Frodo161 Date: Sat, 4 Nov 2023 15:09:13 +0100 Subject: [PATCH] Add constraint to AnnotationsController --- app/controllers/annotations_controller.rb | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/app/controllers/annotations_controller.rb b/app/controllers/annotations_controller.rb index b13a78241..d9f545c07 100644 --- a/app/controllers/annotations_controller.rb +++ b/app/controllers/annotations_controller.rb @@ -35,6 +35,8 @@ def create @annotation = Annotation.new(annotation_params) return unless is_valid_color(@annotation.color) + return if @annotation.category_for_database == Annotation.categories[:content] and + @annotation.subcategory.nil? @annotation.public_comment_id = post_comment(@annotation) @annotation.user_id = current_user.id @@ -50,6 +52,8 @@ def update @annotation.assign_attributes(annotation_params) return unless is_valid_color(@annotation.color) + return if @annotation.category_for_database == Annotation.categories[:content] and + @annotation.subcategory.nil? @annotation.public_comment_id = post_comment(@annotation) @annotation.save