aboutsummaryrefslogtreecommitdiff
path: root/app/models/category.rb
blob: 6868bf712c116646d40b678a0274bea7e22e9f72 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
# SPDX-FileCopyrightText: 2020 IN COMMON Collective <collective@incommon.cc>
#
# SPDX-License-Identifier: AGPL-3.0-or-later

class Category < ApplicationRecord
  belongs_to :taxonomy
  has_many :sections,
           -> { order(rank: :asc) },
           dependent: :destroy,
           inverse_of: :category

  acts_as_list column: :rank, scope: :taxonomy

  validates :name,
            presence: true,
            uniqueness: { scope: :taxonomy_id },
            length: 3..64
end