From 27ef0d45ddc986580aecf8a5a58ba9a2714a3564 Mon Sep 17 00:00:00 2001 From: Karol Date: Tue, 8 Oct 2019 18:44:45 +0200 Subject: [PATCH] add unpublished validation --- app/models/exercise.rb | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/app/models/exercise.rb b/app/models/exercise.rb index f975c45e..71ec0afb 100644 --- a/app/models/exercise.rb +++ b/app/models/exercise.rb @@ -31,8 +31,9 @@ class Exercise < ApplicationRecord validate :valid_main_file? validates :description, presence: true - # validates :execution_environment_id, presence: true # TODO make this conditional - but based on what? + validates :execution_environment_id, presence: true, if: -> { !unpublished? } # TODO make this conditional - but based on what? validates :public, boolean_presence: true + validates :unpublished, boolean_presence: true validates :title, presence: true validates :token, presence: true, uniqueness: true validates_uniqueness_of :uuid