Improve controllers and views

This commit is contained in:
2026-07-28 00:46:33 +02:00
parent eb2797bd90
commit eae0ee9d20
9 changed files with 25 additions and 28 deletions

View File

@@ -13,6 +13,7 @@ class Quantity < ApplicationRecord
errors.add(:parent, :self_reference) if id == parent_id
end
validate if: ->{ parent.present? }, on: :update do
# TODO: should not report error for (parent == self)
errors.add(:parent, :descendant_reference) if ancestor_of?(parent)
end
validates :name, presence: true, uniqueness: {scope: [:user_id, :parent_id]},