1
0
mirror of https://github.com/LaCasemate/fab-manager.git synced 2024-12-03 14:24:23 +01:00
fab-manager/app/models/product_category.rb

13 lines
408 B
Ruby

# frozen_string_literal: true
# Category is a first-level filter, used to categorize Products.
# It is mandatory to choose a Category when creating a Product.
class ProductCategory < ApplicationRecord
validates :name, :slug, presence: true
belongs_to :parent, class_name: 'ProductCategory'
has_many :children, class_name: 'ProductCategory', foreign_key: :parent_id
acts_as_list scope: :parent
end