Unit: limit symbol length, change name:string -> description:text

Closes #11
Closes #12
This commit is contained in:
2024-11-24 15:13:59 +01:00
parent d6fdff252a
commit 3711251656
6 changed files with 28 additions and 16 deletions

View File

@@ -1,5 +1,5 @@
class Unit < ApplicationRecord
ATTRIBUTES = [:symbol, :name, :multiplier, :base_id]
ATTRIBUTES = [:symbol, :description, :multiplier, :base_id]
belongs_to :user, optional: true
belongs_to :base, optional: true, class_name: "Unit"
@@ -11,7 +11,7 @@ class Unit < ApplicationRecord
end
validates :symbol, presence: true, uniqueness: {scope: :user_id},
length: {maximum: columns_hash['symbol'].limit}
validates :name, length: {maximum: columns_hash['name'].limit}
validates :description, length: {maximum: columns_hash['description'].limit}
validates :multiplier, numericality: {equal_to: 1}, unless: :base
validates :multiplier, numericality: {other_than: 0}, if: :base