From 0cf45c77f69387b0e1083282cc1be4ab9431f7be Mon Sep 17 00:00:00 2001 From: Cesar Diaz Date: Fri, 14 Jul 2023 17:18:21 -0300 Subject: [PATCH] added validations to avoid duplication of country and language rules --- app/models/rule_country.rb | 2 ++ app/models/rule_language.rb | 2 ++ 2 files changed, 4 insertions(+) diff --git a/app/models/rule_country.rb b/app/models/rule_country.rb index eb5485e4f..66e769417 100644 --- a/app/models/rule_country.rb +++ b/app/models/rule_country.rb @@ -1,3 +1,5 @@ class RuleCountry < ApplicationRecord belongs_to :tool_group + + validates :tool_group_id, uniqueness: { scope: [:countries, :negative_rule], message: "combination already exists" } end diff --git a/app/models/rule_language.rb b/app/models/rule_language.rb index cef79d79f..c73879ba2 100644 --- a/app/models/rule_language.rb +++ b/app/models/rule_language.rb @@ -1,3 +1,5 @@ class RuleLanguage < ApplicationRecord belongs_to :tool_group + + validates :tool_group_id, uniqueness: { scope: [:languages, :negative_rule], message: "combination already exists" } end