1
0

Fixed Quantity defaults import after removing :name uniqueness

Added awesome_nested_set #each_with_path
This commit is contained in:
cryptogopher
2020-06-20 00:52:37 +02:00
parent 61498018e7
commit 4df88598f8
6 changed files with 35 additions and 7 deletions

View File

@@ -22,8 +22,8 @@ class Quantity < ActiveRecord::Base
# TODO: :name should be validated against model names (Meal, Ingredient etc.)
# Quantity :name uniqueness relaxed to formulas unambiguity
validates :name, presence: true, uniqueness: {scope: [:project_id, :parent_id]}
# Formula ambiguity vlidation delayed after save, as otherwise there seems to
# be no other way to validate against newly changed :name
# Formula ambiguity validation delayed after_save, as there seems to be no
# other way to validate against newly changed Quantity :name from Formula
after_save do
next unless name_changed? || changes.empty?
formulas = Formula.joins(:quantity).where(quantities: {project_id: project})