Manuel Bustillo cc45b4c16e
All checks were successful
Run unit tests / unit_tests (pull_request) Successful in 1m35s
Define a hierarchy of groups
2024-08-11 17:26:43 +02:00

8 lines
249 B
Ruby

class Group < ApplicationRecord
validates :name, uniqueness: true
validates :name, :order, presence: true
has_many :children, class_name: 'Group', foreign_key: 'parent_id'
belongs_to :parent, class_name: 'Group', optional: true
end