From 5e3322fe96fee14bd14c80fd7e28fd2d4978c69c Mon Sep 17 00:00:00 2001 From: cryptogopher Date: Sat, 25 Apr 2020 01:08:33 +0200 Subject: [PATCH] Removed quantity uniqueness validation --- app/models/nutrient.rb | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/app/models/nutrient.rb b/app/models/nutrient.rb index 418e4f7..45b9fc4 100644 --- a/app/models/nutrient.rb +++ b/app/models/nutrient.rb @@ -3,6 +3,8 @@ class Nutrient < ActiveRecord::Base belongs_to :quantity, required: true belongs_to :unit, required: true - validates :quantity, uniqueness: {scope: :food_id} + # Uniqueness is checked exclusively on Food level (see Readout model for details) + #validates :quantity, uniqueness: {scope: :food_id} + validates :amount, numericality: {greater_than_or_equal_to: 0.0} end