diff --git a/app/models/quantity.rb b/app/models/quantity.rb index ed81124..41560e2 100644 --- a/app/models/quantity.rb +++ b/app/models/quantity.rb @@ -16,7 +16,7 @@ class Quantity < ApplicationRecord end validates :name, presence: true, uniqueness: {scope: [:user_id, :parent_id]}, length: {maximum: type_for_attribute(:name).limit} - validates :description, length: {maximum: type_for_attribute(:description).limit} + validates :description, length: {maximum: type_for_attribute(:description).limit} if type_for_attribute(:description).limit # Update :depths of progenies after parent change before_save if: :parent_changed? do diff --git a/app/models/unit.rb b/app/models/unit.rb index 18ef123..91e72f7 100644 --- a/app/models/unit.rb +++ b/app/models/unit.rb @@ -13,7 +13,7 @@ class Unit < ApplicationRecord end validates :symbol, presence: true, uniqueness: {scope: :user_id}, length: {maximum: type_for_attribute(:symbol).limit} - validates :description, length: {maximum: type_for_attribute(:description).limit} + validates :description, length: {maximum: type_for_attribute(:description).limit} if type_for_attribute(:description).limit validates :multiplier, numericality: {equal_to: 1}, unless: :base validates :multiplier, numericality: {greater_than: 0, precision: true, scale: true}, if: :base